Watch Me Code, Episode 5

Written by: Stephen Connolly
2 min read
Stay connected

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 controller and encode it within an API that other Jenkins controllers 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:
    asfMavenTlpStdBuild(jdks:[7,8,9], os:['linux','windows'])

  • 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 controller specific environment details into a separate repository allowing other Jenkins controllers to use our build without having to change their global configuration. This also allows us to change the Jenkins controller 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:

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.