Today’s episode of “Watch Me Code,” continues on from Episode 4 in developing the shared pipeline library to use for building projects for the Apache Maven project.
The mission of the Apache Software Foundation is to provide software for the public good. Since the Jenkinsfile will be part of the source code and hence released with the Apache Maven project, the Apache Maven project needs to ensure that the Jenkinsfile can be used by others. This is probably not a goal that everyone would share, but it means that we need a way to extract the information that is specific to a particular Jenkins master and encode it within an API that other Jenkins masters can then implement.
By the end of this episode we have:
- A very simple API for the Jenkinsfile in each Git repo that allows for a full matrix of builds across different JDKs and operating systems with the configuration of the scope of the matrix being the responsibility of the repository:
- The build uses build resources in parallel to get the result as fast as possible, but will fail fast to minimize resource wastage.
- We have extracted the Jenkins master specific environment details into a separate repository allowing other Jenkins masters to use our build without having to change their global configuration. This also allows us to change the Jenkins master configuration more easily.
If you are interested in the source code of the shared libraries, I have published it in this gist.
Stephen Connolly is a member of the engineering team at CloudBees. He has over 20 years experience in software development. He is involved in a number of open source projects, including Jenkins and Apache. Stephen was one of the first non-Sun committers to the Jenkins project and developed the weather icons. Stephen lives in Dublin, Ireland - where the weather icons are particularly useful. Follow Stephen on Twitter and on his blog.
Check out the entire series:
- Watch Me Code - Episode 1
- Watch Me Code - Episode 2
- Watch Me Code - Episode 3
- Watch Me Code - Episode 4
- Watch Me Code - Episode 5
- Watch Me Code - Episode 6
- Watch Me Code - Episode 7
- Watch Me Code - Episode 8
- Watch Me Code - Episode 9
- Watch Me Code - Episode 10
- Watch Me Code - Episode 11