I am trying to implement parallelization in my Jenkins pipeline code where I can run two stages in parallel. I know this is possible in declarative pipeline, but I am using scripted pipeline.
I've attempted to implement this by doing something like this:
parallel(
stage('StageA') {
echo "This is branch a"
},
stage('StageB') {
echo "This is branch b"
}
)
When I run this and look at this in Blue ocean, the stages do not run in parallel, but instead, StageB is executed after StageA. Is it possible to have parallel stages in scripted jenkins pipeline? If so, how?
This means that one stage could run on a certain machine, and another stage of the same pipeline could run on another machine. Thus having a Jenkins distributed build and not just a Jenkins parallel build.
Jenkins Pipeline allows you to compose multiple steps in an easy way that can help you model any sort of automation process. Think of a "step" like a single command which performs a single action. When a step succeeds it moves onto the next step. When a step fails to execute correctly the Pipeline will fail.
Try this syntax for scripted pipeline:
parallel(
"StageA": {
echo "This is branch a"
},
"StageB": {
echo "This is branch b"
}
)
It should look like this in Blue Ocean, this is what you expect right?
If you want to see the stages (and console output) in the classic view, you can use stage like this:
parallel(
"StageA": {
stage("stage A") {
echo "This is branch a"
}
},
"StageB": {
stage("stage B") {
echo "This is branch b"
}
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With