Jenkins Pipeline – Using Parameterized Trigger Plugin

Jenkinsjenkins-multibranch

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).

Best Answer

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.