HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to rebuild multiple jobs at the same time in Jenkins?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
samethejenkinstimerebuildjobsmultiplehow

Problem

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?

Solution

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}"]
]

Code Snippets

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}"]
]

Context

StackExchange DevOps Q#175, answer score: 8

Revisions (0)

No revisions yet.