9

I'm using Jenkins Rebuild Plugin to execute a parametrized builds with a single Rebuild button. However when I need to rerun dozens of parametrized jobs (either selected, or from the same folder), it's still not efficient.

Is there any simpler way (eventually using different plugin) to re-run multiple jobs at the same time using the last used parameters?

  • 2
    I'm not aware of a plugin that does multi-rebuild. But I can suggest to maybe take a different approach and use a retry based solution, where any failing build retries itself (according to some configuration). That would sort of make the need to multi-rebuild redundant (at least in some cases). – Assaf Lavie Mar 1 '17 at 14:17
8

You can use a pipeline to tie the jobs together, executing them either in parallel or sequentially through steps.
You can pass the relevant parameters to each job as you call it from the pipeline script.
Then you just need to rebuild a single pipeline job. You can tie the jobs together with a common build name through a variable as well.

build job: 'buildjob1', parameters: [
  [$class: 'StringParameterValue', name: 'BUILD_NAME', value: ${env.JOB_BASE_NAME}-${env.BUILD_NUMBER}"], 
  [$class: 'StringParameterValue', name: 'FIXEDPARAM', value: 'some-string'],
  [$class: 'StringParameterValue', name: 'PARAM1', value: "${PARAM1}"]
]
1

You can also build a list of parameter objects, then pass that into the build step:

def paramsMap = [:]
paramsMap['param1'] = 'value1'
paramsMap['param2'] = 'value2'
def paramsObjects = []
paramsMap.each {
  key, value ->
    paramsObjects.push([$class: 'StringParameterValue', name: key, value: value])
}
build job: jobName, parameters: paramsObjects

paramsObjects would look like this:

[
    [$class:StringParameterValue, name:param1, value:value1],
    [$class:StringParameterValue, name:param2, value:value2]
]

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.