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
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
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.
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.
The second Jenkins job is now completed and the first stages of a build pipeline are present.