diff --git a/Jenkinsfile b/Jenkinsfile index 30479827d91..9a0611c4f44 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,11 +53,18 @@ pipeline { steps { pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) deleteDir() - gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) + // Here we do a checkout into a temporary directory in order to have the + // side-effect of setting up the git environment correctly. + gitCheckout(basedir: "${pwd(tmp: true)}", githubNotifyFirstTimeContributor: true) + dir("${BASE_DIR}") { + // We use a raw checkout to avoid the many extra objects which are brought in + // with a `git fetch` as would happen if we used the `gitCheckout` step. + checkout scm + } stashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") dir("${BASE_DIR}"){ - // Skip all the stages except docs for PR's with asciidoc and md changes only - setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true).toString()) + // Skip all the stages except docs for PR's with asciidoc, md or deploy k8s templates changes only + setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '(.*\\.(asciidoc|md)|deploy/kubernetes/.*-kubernetes\\.yaml)' ], shouldMatchAll: true).toString()) setEnvVar('GO_MOD_CHANGES', isGitRegionMatch(patterns: [ '^go.mod' ], shouldMatchAll: false).toString()) setEnvVar('PACKAGING_CHANGES', isGitRegionMatch(patterns: [ '^dev-tools/packaging/.*' ], shouldMatchAll: false).toString()) setEnvVar('GO_VERSION', readFile(".go-version").trim())