diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 8b50599bb28..82035cd1934 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -46,6 +46,11 @@ pipeline { deleteDir() gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) stash allowEmpty: true, name: 'source', useDefaultExcludes: false + dir("${BASE_DIR}"){ + setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true).toString()) + setEnvVar('PACKAGING_CHANGES', isGitRegionMatch(patterns: [ '(^dev-tools/packaging/.*|.ci/Jenkinsfile)' ], shouldMatchAll: false).toString()) + setEnvVar('K8S_CHANGES', isGitRegionMatch(patterns: [ '(^deploy/kubernetes/.*|^version/docs/version.asciidoc)' ], shouldMatchAll: false).toString()) + } } } stage('Lint'){ @@ -66,6 +71,17 @@ pipeline { } } stage('Test') { + when { + // Always when running builds on branches/tags + // On a PR basis, skip if changes are only related to docs. + anyOf { + not { changeRequest() } // If no PR + allOf { // If PR and no docs changes + expression { return env.ONLY_DOCS == "false" } + changeRequest() + } + } + } failFast false matrix { agent {label "${PLATFORM}"} @@ -108,10 +124,15 @@ pipeline { } stage('K8s') { when { - // TODO: Run only if changes in - // - "^deploy/kubernetes/.*" - // - "^version/docs/version.asciidoc" - expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' } + // Always when running builds on branches/tags + // Enable if k8s related changes. + allOf { + expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' } + anyOf { + not { changeRequest() } // If no PR + expression { return env.K8S_CHANGES == "true" } + } + } } steps { runK8s(k8sVersion: 'v1.23.0', kindVersion: 'v0.11.1', context: "K8s-${PLATFORM}") @@ -124,7 +145,8 @@ pipeline { anyOf { expression { return env.GITHUB_COMMENT?.contains('package') } expression { matchesPrLabel(label: 'ci:package') } - // not { changeRequest() } + not { changeRequest() } + expression { return env.PACKAGING_CHANGES == "true" } } // Run packaging only for the linux specific arch expression { return (PLATFORM.contains('ubuntu') || PLATFORM.contains('aarch64')) } @@ -170,10 +192,17 @@ pipeline { } stage('K8s') { when { - // TODO: Run only if changes in - // - "^deploy/kubernetes/.*" - // - "^version/docs/version.asciidoc" - not { changeRequest() } + // Always when running builds on branches/tags + // On a PR basis, skip if changes are only related to docs. + // Enable if k8s related changes. + anyOf { + not { changeRequest() } // If no PR + allOf { // If PR and no docs changes + expression { return env.ONLY_DOCS == "false" } + changeRequest() + } + expression { return env.K8S_CHANGES == "true" } // If k8s changes + } } steps { runAllK8s(["v1.23.0", "v1.22.0", "v1.21.1", "v1.20.7", "v1.19.11", "v1.18.19"])