Test Drive Jenkins using Docker — Part III

Image for post
Image for post

…Continued from Part II

Instructions Summary

Part I

  1. Install Docker
  2. Clone repository from GitHub
  3. Download and start up Jenkins

Part II

  1. Add new project “PULLCODE” to connect to GitHub repository
  2. Add new project “BUILD” to build project with Maven
  3. Run MariaDB and test BUILD

Part III

  1. Part III: Install and create Build Pipeline
  2. Part III: Install JaCoCo to check for test coverage
  3. Part III: Install Build Monitor View and schedule run interval

1. Install and Create Build Pipeline

Install Build Pipeline Plugin. (You may need to restart Jenkins if it advise you to do so.)

Image for post
Image for post

Go back to the dashboard, click + tab.

Image for post
Image for post

Select Build Pipeline View and name your view.

Image for post
Image for post

In Pipeline Flow section, set Select Initial Job to PULLCODE. In the Display Options section, set No Of Displayed Build to 5. You may set the Column Headers to Just the build name and number.

Image for post
Image for post

You will see your pipeline view.

Image for post
Image for post

Next, you want PULLCODE to trigger BUILD automatically.

Go to PULLCODE’s config. In Post-build Actions section, add an action of Trigger parameterized build on other project. Input BUILD into Projects to build field and select Trigger build without parameters. Click Save.

Image for post
Image for post

Go back to your pipeline view and you will see both jobs are linked in the pipeline. Click Run to start the pipeline.

Image for post
Image for post

The PULLCODE will be start.

Image for post
Image for post

Once PULLCODE is finished successfully then BUILD will be started automatically in a while.

Image for post
Image for post

Now your pipeline is finished successfully (indicated by green background).

Image for post
Image for post

PS: You may need to Enable Auto Refresh to get the screen refreshed automatically.

Image for post
Image for post

2. Install JaCoCo to Check for Test Coverage

Install JaCoCo plugin.

Image for post
Image for post

Go to BUILD’s config. In Post-build Actions, add an action of Record JaCoCo coverage report. Leave the default settings and click Save.

Image for post
Image for post

Try to build the project and you will JaCoCo report of coverage.

Image for post
Image for post

Try to change the coverage thresholds so the project is fell in between the maximum and minimum thresholds and select Change build status according the thresholds.

Image for post
Image for post

Now, your build is finished in UNSTABLE status (indicated by yellow color).

Image for post
Image for post

You may try to change the coverage thesholds again so the project is fell below the minimum thresholds and it will finished in FAILURE status (indicated by red color).

Image for post
Image for post

3. Install Build Monitor View and Schedule Run Interval

Install Build Monitor View plugin.

Image for post
Image for post

Add a new Build Monitor View.

Image for post
Image for post

Select BUILD and PULLCODE to display on the monitor.

Image for post
Image for post

Now, you have a real-time monitor screen of your Continuous Integration pipeline.

Image for post
Image for post

Next, you will schedule PULLCODE to run when there is a change committed to GitHub.

Go to PULLCODE’s config. In the Build Triggers, select Poll SCM and input * * * * * in the Schedule field to check for changes in GitHub every minutes.

Image for post
Image for post

Try to make a change on GitHub and commit change and you will see from the pipeline monitor that the it will be automatically built in a while. Try to make changes to the coverage thresholds so our project is back in green.

Image for post
Image for post

That’s it! Hope this is useful 😉

Go back to Part I
Go back to Part II

Related Blog

Originally published at pacroy.blogspot.com on December 25, 2016.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store