KBEC-00517 - How to start a multi-valued parameterized Jenkins job

1 minute readKnowledge base

Issue

EC-Jenkins plugins provides an integration with a Jenkins CI server, allowing a CloudBees CD/RO user the ability to perform several operations on a Jenkins job. To trigger Jenkins jobs, the EC-Jenkins plugin uses the Jenkins REST API. Active Choices Jenkins plugin offers the possibility to have multi-valued parameters in different shapes. This article explains a way to use the EC-Jenkins plugin to trigger a multi-valued parameterized Jenkins job.

INFO: Active Choices plugin is a community plugin. As indicated in our CloudBees plugin support policies, we have limitations on the support we can provide for these plugins. Since these plugins are contributed by third parties, we cannot guarantee bug fixes or other resolutions.

Resolution

To execute a Jenkins job with a multi-choice parameter via the REST API, you need to pass the <parameter-name>:<parameter-value> pair in the REST call once per value desired for the parameter, like in the following example:

curl -X POST <jenkins-url>/job/BUILDNAME/buildWithParameters?<multi-parameter-name>=value1&<multi-parameter-name>=value2&<multi-parameter-name>=value3 ...

Consequently, to start the same multi-valued parameterized Jenkins job from the CloudBees CD/RO server, you need to configure the Parameters field of the EC-Jenkins task like in one of the next examples:

  • as comma-separated list of key-value pairs

<multi-parameter-name>=value1,<multi-parameter-name>=value2,<multi-parameter-name>=value3 ...
  • as JSON content

{"<multi-parameter-name1>":"value1","<multi-parameter-name>":"value2","<multi-parameter-name>":"value3",...}

Tested product/plugin versions

  • CloudBees CD/RO v2023.10

  • EC Jenkins plugin v2.5.0

  • CloudBees CI 2.346.4.1