I got code that list all branches and stages for my pipeline
def build_jobs = [:]
build_jobs['1'] = {
node('builder'){
stage('A'){
sh 'echo 1'
printMyStage()
}
stage('B'){
printMyStage()
"error"
}
}
}
build_jobs['2'] = {
node('builder'){
printMyStage()
sh 'echo 2'
}
}
build_jobs['3'] = {
node('builder'){
stage('A'){
printMyStage()
sh 'echo 3'
}
stage('B'){
printMyStage()
}
}
}
parallel build_jobs
How I can know for each inner stage which branch I am running
For example, expected result for running printMyStage() will be:
branch 1 stage A
branch 1 stage B
branch 2
branch 3 stage A
branch 3 stage B
You can simply do the following within the stage to get the stage name.
Update
Output