O'Reilly logo

Jenkins: The Definitive Guide by John Ferguson Smart

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating Your Maven Build Jobs Automatically

Contributed by Evgeny Goldin

As mentioned in the previous section, the number of build jobs that your Jenkins server will host can vary. As the number of build jobs grows, it becomes harder not only to view them in Jenkins dashboard, but to configure them as well. Imagine what would it take to configure 20 to 50 Jenkins jobs one-by-one! In addition, many of those jobs may have common configuration elements, such as Maven goals or build memory settings, which results in duplicated configuration and higher maintenance overhead.

For example, if you decide to run mvn clean install instead of mvn clean deploy for your release jobs and switch to alternative deployment methods, such as those provided by Artifactory plugin, you’ll have no choice but to visit all relevant jobs and update them manually.

Alternatively, you could take an advantage of the fact that Jenkins is a simple and straightforward tool that keeps all of its definitions in plain files on the disk. Indeed you can update the config.xml files of your jobs directly in the .jenkins/jobs directory where they are kept. While this approach will work, it is still far from ideal as it involves quite a lot of manual picking and fragile replacements in Jenkins XML files.

There is a third way to achieve the nirvana of massive job updates: generate your configuration files automatically using some sort of definition file. The Maven Jenkins Plugin does exactly that, generating config.xml files ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required