Created
May 10, 2024 10:34
-
-
Save actionjack/e33cd9b59f32ce65cf56713437ee5ca5 to your computer and use it in GitHub Desktop.
Parallelise Jenkins components in Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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