From a62db30e476bb366de70607a836da731700f0a76 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 29 Sep 2020 12:13:53 +0100 Subject: [PATCH 1/6] [CI] Support skip-build-ci label --- Jenkinsfile | 17 ++++++++++++----- Jenkinsfile.yml | 8 +++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 119cea9b3ab..2c39bb3b90d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,13 +102,20 @@ pipeline { script { def mapParallelTasks = [:] def content = readYaml(file: 'Jenkinsfile.yml') - content['projects'].each { projectName -> - generateStages(project: projectName, changeset: content['changeset']).each { k,v -> - mapParallelTasks["${k}"] = v + if (content?.disabled?.when && beatsWhen(project: 'top-level', content: content?.disabled?.when)) { + def message = 'Pull Request has been configured to be disabled when there is a skip-ci label match' + warnError(message) { + error message } + } else { + content['projects'].each { projectName -> + generateStages(project: projectName, changeset: content['changeset']).each { k,v -> + mapParallelTasks["${k}"] = v + } + } + notifyBuildReason() + parallel(mapParallelTasks) } - notifyBuildReason() - parallel(mapParallelTasks) } } } diff --git a/Jenkinsfile.yml b/Jenkinsfile.yml index 2f720bf055b..0240e185f04 100644 --- a/Jenkinsfile.yml +++ b/Jenkinsfile.yml @@ -38,10 +38,8 @@ changeset: - "^testing/.*" - "^x-pack/libbeat/.*" -## Proposal -## TBC: This will allow to configure what to do based on the PR configuration disabled: when: - labels: ## Skip the GitHub Pull Request builds if there is a GitHub label match - - "skip-ci" - draft: true ## Skip the GitHub Pull Request builds with Draft PRs. + skip-ci-build-label: true ## Skip the GitHub Pull Request builds if skip-ci-build label has been assigned to the PR + ## TODO: This will allow to configure what to do based on the PR configuration + draft: true ## Skip the GitHub Pull Request builds with Draft PRs. \ No newline at end of file From 84d1c085dd0f91d23cc004eb2eccc6520a6cd274 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 29 Sep 2020 13:19:55 +0100 Subject: [PATCH 2/6] [CI] Support disabled --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2c39bb3b90d..d05ac0bdf88 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,7 +102,8 @@ pipeline { script { def mapParallelTasks = [:] def content = readYaml(file: 'Jenkinsfile.yml') - if (content?.disabled?.when && beatsWhen(project: 'top-level', content: content?.disabled?.when)) { + println content + if (content?.disabled?.when?.labels && beatsWhen(project: 'top-level', content: content?.disabled?.when)) { def message = 'Pull Request has been configured to be disabled when there is a skip-ci label match' warnError(message) { error message From 2bf8051a7af0127c6d07a33731f84b63bfc6f91b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Sep 2020 10:43:09 +0100 Subject: [PATCH 3/6] Support labels --- Jenkinsfile.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile.yml b/Jenkinsfile.yml index 0240e185f04..88050ac0714 100644 --- a/Jenkinsfile.yml +++ b/Jenkinsfile.yml @@ -40,6 +40,8 @@ changeset: disabled: when: - skip-ci-build-label: true ## Skip the GitHub Pull Request builds if skip-ci-build label has been assigned to the PR + labels: ## Skip the GitHub Pull Request builds if any of the given GitHub labels match with the assigned labels in the PR. + - skip-ci + - skip-ci-build ## TODO: This will allow to configure what to do based on the PR configuration draft: true ## Skip the GitHub Pull Request builds with Draft PRs. \ No newline at end of file From e4cd0be0340cca9ab3abd202090ddc04108cb7ab Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Sep 2020 17:06:23 +0100 Subject: [PATCH 4/6] For testing purposes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d05ac0bdf88..35ede29de22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -115,7 +115,7 @@ pipeline { } } notifyBuildReason() - parallel(mapParallelTasks) + //parallel(mapParallelTasks) } } } From 2a3d98f4a852ff496a3b756cda518d1eb0311f95 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 2 Oct 2020 15:10:36 +0100 Subject: [PATCH 5/6] use one label and error --- Jenkinsfile | 7 ++----- Jenkinsfile.yml | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3d5c5cba0dd..a9eb53c49eb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,10 +105,7 @@ pipeline { def content = readYaml(file: 'Jenkinsfile.yml') println content if (content?.disabled?.when?.labels && beatsWhen(project: 'top-level', content: content?.disabled?.when)) { - def message = 'Pull Request has been configured to be disabled when there is a skip-ci label match' - warnError(message) { - error message - } + error 'Pull Request has been configured to be disabled when there is a skip-ci label match' } else { content['projects'].each { projectName -> generateStages(project: projectName, changeset: content['changeset']).each { k,v -> @@ -116,7 +113,7 @@ pipeline { } } notifyBuildReason() - //parallel(mapParallelTasks) + parallel(mapParallelTasks) } } } diff --git a/Jenkinsfile.yml b/Jenkinsfile.yml index 4bffa2f0049..f7b21e1cbdf 100644 --- a/Jenkinsfile.yml +++ b/Jenkinsfile.yml @@ -44,6 +44,5 @@ disabled: when: labels: ## Skip the GitHub Pull Request builds if any of the given GitHub labels match with the assigned labels in the PR. - skip-ci - - skip-ci-build ## TODO: This will allow to configure what to do based on the PR configuration draft: true ## Skip the GitHub Pull Request builds with Draft PRs. \ No newline at end of file From 956e92ff584e7d8f3f7e73ab450b460a8172f127 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 2 Oct 2020 15:16:17 +0100 Subject: [PATCH 6/6] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a9eb53c49eb..93afc3b8f5a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -103,7 +103,6 @@ pipeline { script { def mapParallelTasks = [:] def content = readYaml(file: 'Jenkinsfile.yml') - println content if (content?.disabled?.when?.labels && beatsWhen(project: 'top-level', content: content?.disabled?.when)) { error 'Pull Request has been configured to be disabled when there is a skip-ci label match' } else {