I'm trying to get a pipeline that would have 2 steps running in parallel where the YAML looks like:
steps:
- step: Step1
stages:
- stage: Build
steps:
- *build_a
- *build_b
- *build_c
- stage: Sniff
steps:
- *sniff
- stage: Accept
steps:
- *regress
- *test_suite_a
- *slow_build_that_can_run_in_parallel_to_all_the_above
But Jenkins just passes with the above without running anything. So, I also tried putting everything above in a stage and the slow_build_*
ran but Step1
failed to run since it tried to submit the whole step as a batch instead of breaking it into stages.
Is it possible in Jenkins to get multiple stages inside of a step? Or am I doing this wrong?
Here's what you can do:
pipeline {
stages {
stage('This is a Level 1 Stage') {
stages {
stage(This is a level 2 stage') { steps{...} }
stage(This is a level 2 stage') { steps{...} }
stage(This is a level 2 stage') { steps{...} }
}
}
stage('This is a Level 1 Stage') {
stages {
stage(This is a level 2 stage') { steps{...} }
stage(This is a level 2 stage') { steps{...} }
stage(This is a level 2 stage') { steps{...} }
}
}
}
}
Since Jenkins are now allowing nested stages, you can put a stages into a stage to make nested level of stages.
No you can't have stages
in a step
This is from the Pipeline syntax doc .
For stages
Stages
[...]
Allowed: Only once, inside the pipeline block.
For stage
Stage
[...]
Allowed: Inside the stages section.
And for steps
Steps
The steps section defines a series of one or more steps to be executed in a given stage directive.
[...]
Allowed: Inside each stage block.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.