- 
    Bug 
- 
    Resolution: Duplicate
- 
    Major 
- 
    None
In a project with a Dockerfile, This pipeline succeeds:
pipeline {
    agent {
        dockerfile true
    }
    stages {
        stage ('Build') {
            steps {
                sh 'echo "hello"'
            }
        }
    }
}
This pipeline fails:
pipeline {
    agent any
    stages {
        stage ('Build') {
            agent {
                dockerfile true
            }
            steps {
                sh 'echo "hello"'
            }
        }
    }
}
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.
The following also works, because of reuseNode true, but dockerfile would never work without that when inside a state (due to JENKINS-41605). 
pipeline {
    agent any
    stages {
        stage ('Build') {
            agent {
                dockerfile {
                    reuseNode true
                }
            }
            steps {
                sh 'echo "hello"'
            }
        }
    }
}
- duplicates
- 
                    JENKINS-41605 Declarative: agent inside stage does not do automatic checkout scm -         
- Closed
 
-         
- relates to
- 
                    JENKINS-41605 Declarative: agent inside stage does not do automatic checkout scm -         
- Closed
 
-         
- links to
