jenkins the definitive guide

(Jeff_L) #1

12.3.1.3. Deploying a version from a previous Jenkins build


Redeploying a previously-deployed artifact in Jenkins is relatively straightforward. In Section 12.3.1.1,
“Using the Deploy plugin”, we saw how to use the Copy Artifacts and Deploy plugins to deploy a WAR
file built by a previous build job to an application server. What we need to do now is to let the user
specify the version to be deployed, rather than just deploying the latest build.


We can do this using the Parameterized Trigger plugin (see Section 10.2, “Parameterized Build Jobs”).
First, we add a parameter to the build job, using the special “Build selector for Copy Artifact” parameter
type (see Figure 12.4, “Adding a “Build selector for Copy Artifact” parameter”).


Figure 12.4. Adding a “Build selector for Copy Artifact” parameter


This adds a new parameter to your build job (see Figure 12.5, “Configuring a build selector parameter”).
Here you need to enter a name and a short description. The name you provide will be used as an
environment variable passed to the subsequent build steps.


Figure 12.5. Configuring a build selector parameter


The build selector parameter type lets you pick a previous build in a number of ways, including the latest
successful build, the upstream build that triggered this build job, or a specific build. All of these options
will be available to the user when he or she triggers a build. The Default Selector lets you specify which
of these options will be proposed by default.

Free download pdf