How do you set Jenkins stage or pipeline parallel branch status (unstable, failure etc) for use in Stage view and Blue Ocean UI?
The UI response can be achieved by wrapping both the parallel step and the stage step in a try block, throwing the error from the try/catch block within the parallel branch up to the stage block. Not as clean as setting a property but does have the correct UI response for both Blue Ocean and Stage View.
try {
stage('example') {
try {
parallel (
'A' : {
try {
// Example...
}
catch (error) {
// Mark branch as failed somewhere
throw error
}
},
'B' : {
try {
// Example...
}
catch (error) {
// Mark branch as failed somewhere
throw error
}
}
)
}
catch (error) {
throw (error)
}
finally {
// Parallel branch A failed, do you want to continue? etc...
}
}
}
catch (error) {
println (error)
}