3

I need to trigger a Jenkins job from another job and pass various values to it for later conditional logic. It seems the Parameterized Trigger Plugin will do exactly what I need. (https://plugins.jenkins.io/parameterized-trigger)

However this plugin I'm not seeing anything regarding pipeline syntax both on the doc as well as in the syntax builder.

Most all plugins I've used allow use within pipeline scripts. (Jenkinsfiles). They rarely have documentation for syntax but I can typically just use the Syntax builder inside Jenkins to get the right pipeline syntax to use the plugin.

Is it possible to use this plugin within a pipeline (multi-branch pipeline to be specific)?

If not, then is there any alternative ways to do what I need to do from a Jenkins pipeline? (Trigger another job while passing some value/parameter to it).

6

You don't need a plugin at all to do this. The built-in Pipeline build step supports parameters. E.g.:

build(
  job: 'my-job-name',
  parameters: [
    [
      $class: 'StringParameterValue',
      name: 'myStringParameter',
      value: "my value",
    ],
    [
      $class: 'BooleanParameterValue',
      name: 'myBooleanParameter',
      value: true,
    ],
    // etc.
  ],
)

You should also be able to use the syntax generator with the default build step to help generate this code.

  • 1
    Thank you, I'll give this a shot and mark your answer as accepted in a bit. Side question: can you think of why the parameterized plugin mentioned exists at all? – emmdee Jun 8 '18 at 21:57
  • 2
    In Jenkins, everything is implemented as a plugin - even the Pipeline build step I mentioned in my answer is technically a plugin (it gets installed as a dependency of the core Pipeline plugins, so it's treated more like a built-in feature). The Parameterized Build Trigger plugin is an official plugin developed by the Jenkins developers and it dates back to the pre-Pipeline era of Jenkins, when it was one of the easiest ways to trigger a parameterized build from another build. – jayhendren Jun 9 '18 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.