Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save actionjack/e33cd9b59f32ce65cf56713437ee5ca5 to your computer and use it in GitHub Desktop.
Save actionjack/e33cd9b59f32ce65cf56713437ee5ca5 to your computer and use it in GitHub Desktop.
Parallelise Jenkins components in Groovy
def components = ["component1", "component2", "component3", "component4", "component5"]
def processComponent(component) {
echo "Processing $component..."
// Add your processing logic here
sleep 2 // Simulating some processing time
echo "$component processed."
}
stage('Process Components') {
steps {
script {
def componentClosures = components.collectEntries {
[(it): {
processComponent(it)
}]
}
parallel componentClosures
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment