Spring Boot, Jenkins and Docker – Part Four

Following on from the third post in the series, this article will describe basic steps for enhancing our jenkins builds by making a second job that will test our application and link it to the first job via a pipeline.

1) Frontend Test job creation

Log back in to Jenkins as per part 3

Click on ‘New Item‘, a new screen will load.

Enter ‘spring-boot-frontend-test‘ for the ‘Item name

Ensure ‘Copy existing item‘ is selected

Enter ‘spring-boot-frontend‘ in to the ‘Copy from‘ text field

Click ‘OK

This copies all existing settings from the job created in part 3.

Scroll down to the ‘Build triggers‘ section

Untick ‘Poll SCM

Scroll down to the ‘Build‘ section

Enter ‘clean compile test‘ in to the ‘Goals and options‘ field

This will ensure that it builds the application and in this instance also runs the tests.

Scroll down and click ‘Save

2) Linking Jobs

Now we can link the jobs together and visualise them in a pipeline.

Go back to the Jenkins Dashboard by clicking ‘Back to Dashboard

Click the ‘spring-boot-frontend‘ job

Click ‘Configure

Scroll down to ‘Post-build actions

Click ‘Add post-build action’ and choose ‘Trigger parameterized build on other projects

Enter ‘spring-boot-frontend-test’ in to the ‘Projects to build’ field

Click ‘Add Parameters‘ and choose ‘Pass-through Git commit that was built‘ – This ensures that the downstream job will build the same version of code as the upstream job.

Click ‘Save‘ – We now have two jobs that are linked together.

This will return you back to the job screen, again click ‘Back to dashboard‘ to return to the Jenkins dashboard.

3) Visualising jobs in a pipeline

Now we need to create a new Jenkins view to visualise our pipeline.

This time click the ‘+‘ icon shown next to the ‘All’ tab on the Jenkins dashboard as shown in figure 1.

Add Jenkins View
Figure 1 – Add Jenkins View

On the resulting screen enter ‘pipeline‘ (or something similar in to the view name)

Choose ‘Build pipeline view‘ and click ‘OK

You should then see the view configuration screen. Locate the ‘Select Initial Job‘ and ensure that ‘spring-boot-frontend‘ is selected.

Click ‘OK‘ and you should see a screen similar to figure 2 below.

Jenkins pipeline view
Figure 2 – Pipeline view

The second Jenkins job is now completed and the first stages of a build pipeline are present.

Spring Boot, Jenkins and Docker – Part Three

Following on from the second post in the series, this article will describe basic steps for configuring the first pass at our Jenkins pipeline.

1) frontend Build job creation

If you have followed the second post, Jenkins should now be up and running and accessible by going to http://192.168.99.100:8080 (or whatever IP your Docker host is running on).

You should see a screen that resembles figure 1 below.

Image of Jenkins started up
Figure 1 – Image of Jenkins started up

Click on ‘New Item‘, a new screen will load.

Enter ‘spring-boot-frontend‘ for the ‘Item name

Ensure ‘Maven project‘ is selected

Click ‘OK

On the resulting screen under ‘Source code management‘, choose ‘Git

Enter ‘https://github.com/eggsy84/spring-boot-frontend.git‘ in to the ‘Repository URL‘ field. (You can of course change this to your SCM location)

Scroll down to the ‘Build triggers‘ section

Choose ‘Poll SCM‘ and enter ‘* * * * *‘ in to the schedule field (This means poll every minute)

Scroll down to the ‘Build‘ section

Enter ‘clean compile -DskipTests=true‘ in to the ‘Goals and options‘ field

Scroll down and click ‘Save

After clicking Save you will be returned to the job dashboard. A build job should automatically trigger as shown in figure 2.

Jenkins job auto triggered
Figure 2 – Job execution

That job will take a number of minutes to complete whilst it downloads the  various Maven dependencies. You can click in to the job and choose ‘Console’ to monitor the progress.

Once complete the console should look similar to figure 3 below.

Jenkins job success
Figure 3 – Job success

Congratulations, you just created your first Maven based Jenkins job!

Part 4 – Frontend test job creation