From 3f9ebb9b278156fb06ce951e7ab4fbb81e6d40f0 Mon Sep 17 00:00:00 2001 From: Eric Ball Date: Thu, 5 Dec 2019 20:04:19 -0800 Subject: [PATCH] Make gerrit-branch-lock work for all proj/branches Add gerrit-branch-lock to gerrit ci-jobs, and make it so that it can be triggered from any change, for any branch. Issue: RELENG-1236 Change-Id: I757f76c940bdbed10e3c1bc8a422ef94f1495dee Signed-off-by: Eric Ball --- .jjb-test/lf-ci-jobs.yaml | 1 - docs/jjb/lf-ci-jobs.rst | 12 +++++------- jjb/lf-ci-job-groups.yaml | 1 + jjb/lf-ci-jobs.yaml | 13 ++++++------- releasenotes/notes/branch-lock-any-80d1391da7431c02.yaml | 5 +++++ shell/gerrit-branch-lock.sh | 1 + 6 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/branch-lock-any-80d1391da7431c02.yaml diff --git a/.jjb-test/lf-ci-jobs.yaml b/.jjb-test/lf-ci-jobs.yaml index baeced5b..65a4fab2 100644 --- a/.jjb-test/lf-ci-jobs.yaml +++ b/.jjb-test/lf-ci-jobs.yaml @@ -3,7 +3,6 @@ name: gerrit-ci-jobs jobs: - "{project-name}-ci-jobs" - - gerrit-branch-lock project-name: gerrit-ciman diff --git a/docs/jjb/lf-ci-jobs.rst b/docs/jjb/lf-ci-jobs.rst index 3cd6e72f..0fa70814 100644 --- a/docs/jjb/lf-ci-jobs.rst +++ b/docs/jjb/lf-ci-jobs.rst @@ -107,10 +107,13 @@ Job Templates Gerrit Branch Lock ------------------ -Job submits a patch to lock or unlock a project's branch. +Job submits a patch to lock or unlock a project's branch. This should only be +loaded once, as "ci-management-gerrit-branch-lock" (or "ci-management" +equivalent). That job will process lock/unlock requests for all projects and +all branches. :Template Names: - - {project-name}-gerrit-branch-lock-{stream} + - {project-name}-gerrit-branch-lock - gerrit-branch-lock :Comment Trigger: @@ -126,14 +129,9 @@ Job submits a patch to lock or unlock a project's branch. :Optional parameters: - :branch: Git branch to build against. (default: master) :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT) - :stream: Keyword that can be used to represent a release code-name. - Often the same as the branch. (default: master) :submodule-timeout: Timeout (in minutes) for checkout operation. (default: 10) - :submodule-disable: Disable submodule checkout operation. - (default: false) :gerrit_merge_triggers: Override Gerrit Triggers. .. _lf-global-jjb-jenkins-cfg-merge: diff --git a/jjb/lf-ci-job-groups.yaml b/jjb/lf-ci-job-groups.yaml index 81e6b0b9..945079cb 100644 --- a/jjb/lf-ci-job-groups.yaml +++ b/jjb/lf-ci-job-groups.yaml @@ -9,6 +9,7 @@ - gerrit-jjb-deploy-job - gerrit-jjb-merge - gerrit-jjb-verify + - gerrit-branch-lock - job-group: name: "{project-name}-github-ci-jobs" diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 3ec2b499..3106d8bf 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -166,19 +166,18 @@ ###################### - job-template: - name: "{project-name}-gerrit-branch-lock-{stream}" + name: "{project-name}-gerrit-branch-lock" id: gerrit-branch-lock ###################### # Default parameters # ###################### - branch: master + branch: "**" disable-job: false git-url: "$GIT_URL/$GERRIT_PROJECT" - stream: master submodule-timeout: 10 - submodule-disable: false + submodule-disable: true gerrit_merge_triggers: - comment-added-contains-event: comment-contains-value: (un)?lock branch$ @@ -199,7 +198,7 @@ parameters: - lf-infra-parameters: project: "{project}" - stream: "{stream}" + stream: "" branch: "{branch}" wrappers: @@ -211,7 +210,7 @@ - lf-infra-gerrit-scm: git-url: "{git-url}" refspec: "" - branch: "{branch}" + branch: "$GERRIT_BRANCH" submodule-recursive: false submodule-timeout: "{submodule-timeout}" submodule-disable: "{submodule-disable}" @@ -224,7 +223,7 @@ trigger-on: "{obj:gerrit_merge_triggers}" projects: - project-compare-type: ANT - project-pattern: "{project}" + project-pattern: "**" branches: - branch-compare-type: ANT branch-pattern: "**/{branch}" diff --git a/releasenotes/notes/branch-lock-any-80d1391da7431c02.yaml b/releasenotes/notes/branch-lock-any-80d1391da7431c02.yaml new file mode 100644 index 00000000..daee4e7e --- /dev/null +++ b/releasenotes/notes/branch-lock-any-80d1391da7431c02.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add gerrit-branch-lock to gerrit ci-jobs, and make it so that it can be + triggered from any change, for any branch. diff --git a/shell/gerrit-branch-lock.sh b/shell/gerrit-branch-lock.sh index 8cfbe4a1..60f28fe2 100644 --- a/shell/gerrit-branch-lock.sh +++ b/shell/gerrit-branch-lock.sh @@ -39,6 +39,7 @@ install_gerrit_hook # Groups must be mapped in the groups file before they can be used if ! grep 'Registered Users'; then echo -e "global:Registered-Users\tRegistered Users" >> groups + git add groups fi mode=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep branch | awk '{print $1}') -- 2.16.6