How do nested sequential stages work and why are they useful?
IntermediateConceptDeclarative pipeline syntax
Answer
A stage can contain a stages block instead of steps. The child stages run in order and share the parent's agent and workspace, while still appearing individually in the UI.
stage('CI') {
agent { kubernetes { yamlFile 'ci/build-pod.yaml' } }
stages {
stage('Test') { steps { sh 'npm test' } }
stage('Build') { steps { sh 'npm run build' } }
}
}
This is how we combine agent none at the top with one pod for all CI steps.
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?IntermediateWhat do `beforeAgent`, `beforeInput` and `beforeOptions` do inside `when`?Advanced