jenkins the definitive guide

(Jeff_L) #1

Figure 10.45. Viewing the details of a build promotion


Next you need to tell Jenkins what to do when the build is promoted. You do this by adding actions, just
like in a freestyle build job. This makes build promotions extremely flexible, as you can add virtually
any action available to a normal freestyle build job, including any additional steps made available by
the plugins installed on your Jenkins instance. Common actions include invoking Maven or Ant scripts,
deploying artifacts to a Maven repository, or triggering another build job.


One important thing to remember here is that you cannot rely on files in the workspace when promoting
your build. Indeed, by the time you promote the build, either automatically or manually, other build jobs
may have deleted or rewritten the files you need to use. For this reason, it is unwise, for example, to
deploy a WAR file directly from the workspace to an application server from within a build promotion
process. A more robust solution is to trigger a separate build job and to use the Copy Artifacts plugin
(see Section 10.7.2, “Copying Artifacts”) to retrieve precisely the right file. In this case, you will be
copying artifacts that you have configured Jenkins to conserve, rather than copying the files directly
from the workspace.


For build promotion to work correctly, Jenkins needs to be able to precisely link downstream build jobs
to upstream ones. The more accurate way to do this is by using fingerprints. In Jenkins, a fingerprint is
the MD5 checksum a file produced by or used in a build job. By matching fingerprints, Jenkins is able
to identify all of the builds which use a particular file.

Free download pdf