Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Update as of version 2.23 of Parameterized Trigger Plugin:</h2> <p>With version 2.23+ <a href="https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin#ParameterizedTriggerPlugin-Backwardcompatibilitywithversion2.22" rel="noreferrer">behavior changed</a> (thanks <a href="https://stackoverflow.com/users/2383282/abhijeetkamble">AbhijeetKamble</a> for pointing out). Any parameter that is being passed by <strong>Predefined Parameters</strong> section of calling (<strong><em>build</em></strong>) job has to exist in the called (<strong><em>deploy</em></strong>) job. Furthermore, the restrictions of called job's parameters apply, so if the called job's parameter is a <strong>choice</strong>, it has to have all possible values (from promotions) pre-populated. Or just use <strong>Text</strong> parameter type.</p> <h2>Solution</h2> <p>Yes, I have the exact same setup: a <em>build</em> job (based on SVN commits) and manually executed <em>deploy</em> job. When the user selects any build from the <em>build</em> job (including older builds), they can then go to <strong>Promotion Status</strong> link and execute various <em>deploy</em> promotions, for example <em>Deploy to DEV</em>, <em>Deploy to QA</em>, etc</p> <h2>Here is how to setup the promotion on <em>build</em> job:</h2> <ul> <li>You will need these plugins: <a href="https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin" rel="noreferrer"><strong>Parameterized Trigger Plugin</strong></a>, <a href="https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin" rel="noreferrer"><strong>Promoted Builds Plugin</strong></a> </li> <li>You will also need to setup default <strong>Archive the Artifacts</strong> post-build action on this build job.</li> <li>Check mark <strong>Promote builds when</strong></li> <li>Define <strong>Name</strong> "Deploy to DEV"</li> <li>Under <strong>Criteria</strong> check mark <strong>Only when manually approved</strong></li> <li>Under <strong>Actions</strong> use <strong>Trigger/call builds on other projects</strong></li> <li>In <strong>Projects to build</strong> enter the name to your <em>deploy</em> job here</li> <li>Check mark <strong>Block until the triggered projects finish their builds</strong></li> <li><strong>Mark this build as failure if the triggered build is worse or equal to</strong>: FAILURE (adjust according to statuses of your deploy job)</li> <li><strong>Predefined parameters</strong> (Code A)</li> </ul> <p><strong>Code A:</strong></p> <pre><code>Server=IP_of_my_dev_server` Job=$PROMOTED_JOB_NAME` BuildSelection=&lt;SpecificBuildSelector&gt;&lt;buildNumber&gt;$PROMOTED_NUMBER&lt;/buildNumber&gt;&lt;/SpecificBuildSelector&gt; </code></pre> <p>Above, in the <strong>Predefined parameters</strong> section, the name to the left of = are the parameters that are defined in your <em>deploy</em> job. And to the right of = are the values that will be assigned to those parameters when this promotion executes. Defines three parameters <code>Server</code>, <code>Job</code> and <code>BuildSelection</code>.</p> <p>The parameter <code>Server=</code> is my own, as my deploy job can <em>deploy</em> to multiple servers. However if your <em>deploy</em> job is hardcoded to always deploy to a specific location, you won't need that.</p> <p>The <code>Job=</code> parameter is required, but the name of the param depends on what you've setup in your <em>deploy job</em> (I will explain configuration there). The value <code>$PROMOTED_JOB_NAME</code> has to remain as is. This is an environment variable that the promotion process is aware of and refers back to the name of your <em>build</em> job (the one where promotion process is configured)</p> <p>The <code>BuildSelection=</code> parameter is required. This whole line has to remain as is. The value passed is <code>$PROMOTED_NUMBER</code>, which once again the promotion is aware of. In your example, it would be <code>#39</code>.</p> <p>The <strong>Block until the triggered projects finish their builds</strong> check mark will make the promotion process wait until the <em>deploy</em> job finished. If not, the promotion process will trigger the deployment job and quit with success. Waiting for the <em>deploy</em> job to finish has the benefit that if the <em>deploy</em> job fails, the promotion star will be marked with failure too. </p> <p>(One little note here: the promotion star will appear successful <strong>while</strong> the <em>deploy</em> job is running. If there is a deploy failure, it will only change to failure after the <em>deploy</em> job finished. Logical... but can be a bit confusing if you look at the promotion star before the deployment completed)</p> <h2>Here is how to setup <em>deploy</em> job</h2> <ul> <li>You will need <a href="https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin" rel="noreferrer"><strong>Copy Artifacts plugin</strong></a> </li> <li>Under <strong>This build is parameterized</strong></li> <li>Configure a parameter of type <strong>Choice (or Text)</strong> with <strong>name</strong> <code>Server</code> (this name has to match with configuration in promotion's <strong>Predefined Parameters</strong> in previous section)</li> <li>Choices: Enter list of possible server IPs that would be used by the promotion's <strong>Predefined Parameters</strong> in previous section (<em>see update note below</em>) </li> <li>Configure a parameter of type <strong>Choice (or Text)</strong> with <strong>name</strong> <code>Job</code> (this name has to match with configuration in promotion's <strong>Predefined Parameters</strong> in previous section)</li> <li>Choices: Enter the name of your <em>build</em> job as default. <strike>This is only needed if you trigger the <em>deploy</em> job manually. When the <em>deploy</em> job is triggered from promotion, the promotion will supply the value</strike> (the <code>Job=</code> from <strong>Predefined parameters</strong> that we configured). Also, if there is no value passed from promotion's <strong>Predefined parameters</strong>, the first choice value will be used. If you have a 1-to-1 relationship between the <em>build</em> and <em>deploy</em> jobs, you can omit the <code>Job=</code> parameter in promotion's configuration.</li> <li><strong>Update:</strong> <a href="https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin#ParameterizedTriggerPlugin-Backwardcompatibilitywithversion2.22" rel="noreferrer">since version 2.23 of Parameterized Trigger</a>, the available choices in the <strong><em>deploy</em></strong> job configuration have to have all possible values coming from the promotion's predefined parameters. If you don't want that limit, use "Text" instead of "Choice"</li> <li>Configure a parameter of type <strong>Build selector for Copy Artifact</strong> with <strong>name</strong>: <code>BuildSelection</code></li> <li><strong>Default Selector</strong>: Latest successful build</li> <li>Under <strong>Build</strong> steps</li> <li>Configure <strong>Copy artifacts from another project</strong></li> <li>In <strong>Project name</strong> enter <code>${Job}</code></li> <li>At <strong>Which build</strong> choose <code>Specified by a build parameter</code></li> <li>In <strong>Parameter Name</strong> enter <code>BuildSelection</code> (without <code>${...}</code>!)</li> <li>Configure the rest accordingly for your artifacts that will be copied from <em>build</em> job to <em>deploy</em> job's workspace</li> <li>Use the copied artifacts inside the <em>deploy</em> job as you need in order to deploy</li> </ul> <p>So now, with the above <em>deploy</em> job, you can run it manually and select which build number from <em>build</em> job you want to deploy (last build, last successful, by build number, etc). You probably already have it configured very similarly. The <em>promotion</em> on the <em>build</em> job will basically execute the same thing, and supply the build number, based on what promotion was executed.</p> <p>Let me know if you got any issues with the instructions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload