13
votes

I am using Jenkins to create a build pipeline, and need to trigger a deployment step in the pipeline. This means a manual process (the build occurs automatically, timed, then stops at the deployment stage, waiting for manual authorization).

I need the deploy step to also be triggered with parameters from the prior step.

So, using the 'Parameterized plugin' I can pass parameters between jobs. I can trigger automated OR manually triggered downstream jobs (not sure if this is a standard feature, or manual builds was added by some plugin).

However, I cannot find any way to trigger a manual parameterized job.

Does anyone know of a way to do this? Is there another plugin I can use?

The reason I need the parameters is that I have created a generic deployment job, and need to pass in the module name, and maven version to deploy. I could create specific deployment jobs for each module, but this would be very painful.

I have also been considering the following, but it seems a kludge:

  1. Automated job performs build, triggers 'deployment trigger' build, passing parameters.
  2. 'Deployment trigger' writes these parameters to a file on the filesystem (build step - shell execution), and manually triggers the actual deployment job
  3. Deployment job (MUST use the WORKSPACE from the 'deployment trigger' job) reads parameters from the filesystem (using EnvInject plugin).

There are various problems with this approach

  1. I just don't like it.
  2. Has an intermediate jobs just to pass parameters. This clutters the Jenkins workspace
  3. As builds are performed on the same WORKSPACE, seems fragile to me (though workable!)
5
Did you ever come up with a tolerable solution for this?Niklas
No. In the end I automatically triggered an intermediate job, passing parameters to this. This sets the environment vars into a file on the workspace FS. Then I triggered a manual step to run another job on the same environment, which sets up an environment based on the environment file set previously. Hacky.GKelly
I just used a script to echo myparameter=$POM_VERSION >> version.properties at a later step in the build. Then used the EnvInject to read in version.properties in the next build.Jameson Triplett

5 Answers

7
votes

Current production version (1.4.2) of build-pipeline-plugin allows it - to specify manual downstream job with parameters, which is displayed on the pipeline and can be started from there. Old versions couldn't do it.

2
votes

Take a look at the Build Pipeline Plugin: https://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Plugin.

You can specify jobs to be automatically triggered or manually triggered.

Also if you need parameter passing between jobs you will need to download the Groovy Plugin: https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin

In order to pass parameters lets say an SVN revision between jobs you will need to Execute System Groovy Script at the start of your build. This is an example that will add a SVN_UPSTREAM parameter that can be used by any downstream jobs. NOTE: I have noticed a problem with creating a downstream job that also has a system groovy script. It seems to blow away any references to the original parameters created.

import hudson.model.*
def build = Thread.currentThread().executable;
build.addAction(new ParametersAction(new StringParameterValue("SVN_UPSTREAM", build.getEnvVars()['SVN_REVISION'])));
println "SVN_UPSTREAM:" + build.getEnvVars()['SVN_UPSTREAM'];
2
votes

There is a sort of workaround:

  • setup manual promotion (Promote builds when... > Only when manually approved) in upstream job
  • in the promotion specify add Actions > Trigger parameterized build on other projects, specify job and add parameters

Once you manually promote a specific build of upstream job, it will fire up a build of downstream job. But the downstream job will not appear on the pipeline.

1
votes

The Build Pipeline Plugin can do this, but at the time of this writing, not in any released version. I built the plugin from main (rev 392 at the time), which includes the patch mentioned in this issue and it works for me.
When you have that installed, you are able to use a post-build action called "Build other projects (manual step)" in the first job and there you can configure the parameters to be passed to the second (manually triggered) pipeline job.

0
votes

In my opinion there is no possibility to achieve the goal

When you start the pipeline delivery-pipeline-plugin checks only the parameters of first job -> and then display (or not) the initParam screen

But when next step (for example deploy) is manual and it required paramaters then the initParam screen is ignored Look at issue https://issues.jenkins-ci.org/browse/JENKINS-32336