Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
This pipeline succeeds:
pipeline { agent any stages { stage ('Build') { steps { sh 'cat Jenkinsfile' } } } }
This pipeline fails:
pipeline { agent any stages { stage ('Build') { agent any steps { sh 'cat Jenkinsfile' } } } }
The reason this happens is that the agent inside a stage step does not do checkout scm automatically. This is very confusing behavior. Agent initialization should be consistent whether at top or inside a stage.
I would expect to do something like this to make an agent in a stage not do checkout:
pipeline { agent any options { skipDefaultCheckout() } stages { stage ('Build') { agent any options { skipDefaultCheckout() } steps { sh 'cat Jenkinsfile' } } } }
Attachments
Issue Links
- is duplicated by
-
JENKINS-41607 Declarative: agent dockerfile fails when agent inside stage
-
- Closed
-
- relates to
-
JENKINS-41607 Declarative: agent dockerfile fails when agent inside stage
-
- Closed
-
- links to
Activity
Field | Original Value | New Value |
---|---|---|
Description |
This pipeline succeeds: {code:language=groovy} pipeline { agent any stages { stage ('Build') { steps { sh 'cat Jenkinsfile' } } } } {code} This pipeline fails: {code:language=groovy} pipeline { agent any stages { stage ('Build') { agent any steps { sh 'cat Jenkinsfile' } } } } {code} The reason this happens is that the agent inside a stage step does not do checkout scm automatically. This is very confusing behavior. Agent initialization should be consistent whether at top or inside a stage. |
This pipeline succeeds: {code:language=groovy} pipeline { agent any stages { stage ('Build') { steps { sh 'cat Jenkinsfile' } } } } {code} This pipeline fails: {code:language=groovy} pipeline { agent any stages { stage ('Build') { agent any steps { sh 'cat Jenkinsfile' } } } } {code} The reason this happens is that the agent inside a stage step does not do checkout scm automatically. This is very confusing behavior. Agent initialization should be consistent whether at top or inside a stage. I would expect to do something like this to make an agent in a stage not do checkout: {code:language=groovy} pipeline { agent any options { skipDefaultCheckout() } stages { stage ('Build') { agent any options { skipDefaultCheckout() } steps { sh 'cat Jenkinsfile' } } } } {code} |
Link |
This issue relates to |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | In Review [ 10005 ] |
Remote Link | This issue links to "PR #109 (Web Link)" [ 15452 ] |
Link |
This issue is duplicated by |
Resolution | Fixed [ 1 ] | |
Status | In Review [ 10005 ] | Resolved [ 5 ] |
Remote Link | This issue links to "CloudBees Internal OSS-1996 (Web Link)" [ 18472 ] |
Status | Resolved [ 5 ] | Closed [ 6 ] |
The reasoning behind automatic checkout only happening at the top level was a conscious decision - and frankly, one I'd still advocate for. But it may make sense to have a per-stage option for "do a fresh checkout of SCM in this stage" - independent of the agent configuration. There've been some other things that have come up that may make sense as part of a stage-level options section.