darinpope / jenkins-example-parallel Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Hi @darinpope
Love all CloudBee tips on CloudBeeTV.
Can the video/example be extended to include error handling in pipelines?
So, if one of the sequential stages fails within the parallel stage, it stops downstream stages but doesn't stop the other parallel job.
For example, in https://github.com/darinpope/jenkins-example-parallel/blob/main/Jenkinsfile-4, in the stage 'linux-amd64' fails, the stages 'run', 'unit test'.... will be skipped, but the stage 'linux-armv6' & 'darwin-amd64' will continue without issues.
We have a multi-parallel job to build AWS AMIs for different tiers in our environment.
I've managed to cobble something together using a groovy map, but it seems clunky and included some scripted pipeline code.
Below is a stage script where if/try/catch is being used
stage("Configure ${AMITierName} instance") {
script {
if (stageResultMap.find{ it.key == "${role}_Launch" }?.value) {
try {
sh (script: '''
#/bin/bash
/usr/local/bin/ansible-playbook ${WORKSPACE}/ansible/playbooks/${role}_base_build.yml \
--extra-vars "hosts_tag_name=tag_Name_${linuxdistro}_${role}_${arch}_base_build_${DATE}_01";
''')
stageResultMap."${role}_Build" = true
}
catch (Exception e) {
unstable("${STAGE_NAME} failed!")
currentBuild.result = 'UNSTABLE'
stageResultMap."${role}_Build" = false
echo "${stageResultMap}"
}
} else {
Utils.markStageSkippedForConditional("${STAGE_NAME}")
echo "Skip stage ${STAGE_NAME}"
}
}
Is there a better way to handle errors in pipelines? I don't think I can use catchError in this scenario.
Many thanks!!
Tony
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.