osmith submitted this change.

View Change

Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
jenkins-gerrit: fix ambiguous use of review api

Fix an error when the same Change-Id is used on multiple branches or in
theory projects. This is actually allowed by gerrit, and we use this
e.g. when backporting patches from master.

Use the project, change number (e.g. 30147) and patchset number (e.g. 2)
instead of the Change-Id.

Fix for:
+ ssh -p 29418 -l jenkins gerrit.osmocom.org gerrit review 4835a62cd88f0d69db76fb3bfd2df02176a91a6d --json
fatal: "4835a62cd88f0d69db76fb3bfd2df02176a91a6d" matches multiple patch sets

Related: https://gerrit-review.googlesource.com/Documentation/cmd-review.html
Change-Id: I2d627f8f3b400fa57a50a228d47df2194f60fd08
---
M jobs/gerrit-lint.yml
M jobs/gerrit-pipeline-result.yml
M jobs/gerrit-verifications.yml
M lint/lint_diff.sh
M scripts/jenkins-gerrit/pipeline_summary_send.sh
5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/jobs/gerrit-lint.yml b/jobs/gerrit-lint.yml
index 847096b..dfdab5b 100644
--- a/jobs/gerrit-lint.yml
+++ b/jobs/gerrit-lint.yml
@@ -31,6 +31,15 @@
osmo-ci.git branch
default: 'master'
- string:
+ name: GERRIT_PROJECT
+ description: set by gerrit verification pipeline job
+ - string:
+ name: GERRIT_CHANGE_NUMBER
+ description: set by gerrit verification pipeline job
+ - string:
+ name: GERRIT_PATCHSET_NUMBER
+ description: set by gerrit verification pipeline job
+ - string:
name: GERRIT_BRANCH
description: set by gerrit verification pipeline job
- string:
diff --git a/jobs/gerrit-pipeline-result.yml b/jobs/gerrit-pipeline-result.yml
index c3c03b6..94fc88c 100644
--- a/jobs/gerrit-pipeline-result.yml
+++ b/jobs/gerrit-pipeline-result.yml
@@ -29,6 +29,15 @@
osmo-ci.git branch
default: 'master'
- string:
+ name: GERRIT_PROJECT
+ description: set by gerrit verification pipeline job
+ - string:
+ name: GERRIT_CHANGE_NUMBER
+ description: set by gerrit verification pipeline job
+ - string:
+ name: GERRIT_PATCHSET_NUMBER
+ description: set by gerrit verification pipeline job
+ - string:
name: GERRIT_BRANCH
description: set by gerrit verification pipeline job
- string:
diff --git a/jobs/gerrit-verifications.yml b/jobs/gerrit-verifications.yml
index 8649635..2bbfe4e 100644
--- a/jobs/gerrit-verifications.yml
+++ b/jobs/gerrit-verifications.yml
@@ -445,6 +445,9 @@
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {{
env.PIPELINE_LINT_PASSED = "0"
build job: 'gerrit-lint', parameters: [
+ string(name: "GERRIT_PROJECT", value: "${{env.GERRIT_PROJECT}}"),
+ string(name: "GERRIT_CHANGE_NUMBER", value: "${{env.GERRIT_CHANGE_NUMBER}}"),
+ string(name: "GERRIT_PATCHSET_NUMBER", value: "${{env.GERRIT_PATCHSET_NUMBER}}"),
string(name: "GERRIT_BRANCH", value: "${{env.GERRIT_BRANCH}}"),
string(name: "GERRIT_HOST", value: "${{env.GERRIT_HOST}}"),
string(name: "GERRIT_PATCHSET_REVISION", value: "${{env.GERRIT_PATCHSET_REVISION}}"),
@@ -510,6 +513,9 @@
// comment + vote to gerrit
script {{
build job: 'gerrit-pipeline-result', parameters: [
+ string(name: "GERRIT_PROJECT", value: "${{env.GERRIT_PROJECT}}"),
+ string(name: "GERRIT_CHANGE_NUMBER", value: "${{env.GERRIT_CHANGE_NUMBER}}"),
+ string(name: "GERRIT_PATCHSET_NUMBER", value: "${{env.GERRIT_PATCHSET_NUMBER}}"),
string(name: "GERRIT_BRANCH", value: "${{env.GERRIT_BRANCH}}"),
string(name: "GERRIT_HOST", value: "${{env.GERRIT_HOST}}"),
string(name: "GERRIT_PATCHSET_REVISION", value: "${{env.GERRIT_PATCHSET_REVISION}}"),
diff --git a/lint/lint_diff.sh b/lint/lint_diff.sh
index 7ae186f..662bdd3 100755
--- a/lint/lint_diff.sh
+++ b/lint/lint_diff.sh
@@ -68,7 +68,8 @@
"$GERRIT_HOST" \
gerrit \
review \
- "$GERRIT_PATCHSET_REVISION" \
+ --project "$GERRIT_PROJECT" \
+ "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
--json \
< gerrit_report.json
fi
diff --git a/scripts/jenkins-gerrit/pipeline_summary_send.sh b/scripts/jenkins-gerrit/pipeline_summary_send.sh
index c49f428..29ea860 100755
--- a/scripts/jenkins-gerrit/pipeline_summary_send.sh
+++ b/scripts/jenkins-gerrit/pipeline_summary_send.sh
@@ -26,6 +26,7 @@
"$GERRIT_HOST" \
gerrit \
review \
- "$GERRIT_PATCHSET_REVISION" \
+ --project "$GERRIT_PROJECT" \
+ "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
--json \
< gerrit_report.json

To view, visit change 30147. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I2d627f8f3b400fa57a50a228d47df2194f60fd08
Gerrit-Change-Number: 30147
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged