How it works...

The Jenkinsfile describes both how to build and test the software and the environment in which to run such an operation.

Let's take a look at the different sections:

  • agent any specifies that this build can be run on any available executor.
  • The tools {} section specifies the programs needed to run our build. In this case, Maven and the Java Development Kit (JDK) are needed and the versions are specified as well.
  • stages {} and stage() {} allow splitting the run into well-defined sections which will allow better analysis of build results.
  • Each stage needs to contain a steps {} section that will describe exactly which operations to perform. In this case, in the Initialize stage, we are simply running a shell script that echoes ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.