Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41605

Declarative: agent inside stage does not do automatic checkout scm

    Details

    • Similar Issues:

      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

            Activity

            bitwiseman Liam Newman created issue -
            bitwiseman Liam Newman made changes -
            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}
            bitwiseman Liam Newman made changes -
            Link This issue relates to JENKINS-41607 [ JENKINS-41607 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #109 (Web Link)" [ 15452 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-41607 [ JENKINS-41607 ]
            abayer Andrew Bayer made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-1996 (Web Link)" [ 18472 ]
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                bitwiseman Liam Newman
              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: