From c9a399cf1b10ebe7f7faf42952947b8dc8fa98a7 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 7 Apr 2021 16:14:04 +0000 Subject: [PATCH] cloud-infra: fix generate-change-metadata.sh After upgrading Gerrit, it appears that the endpoint being previously used for querying change metadata changed format slightly. In the hope of safeguarding against future upgrades, modifying the dependent change metadata extraction piece to instead use command-line gerrit queries over SSH. Signed-off-by: Cian Johnston Change-Id: I94ca3df2d1033b44bd909e1393947312c76b56f4 --- jjb/cloud-infra/scripts/generate-change-metadata.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jjb/cloud-infra/scripts/generate-change-metadata.sh b/jjb/cloud-infra/scripts/generate-change-metadata.sh index 8b969dc5..75172322 100755 --- a/jjb/cloud-infra/scripts/generate-change-metadata.sh +++ b/jjb/cloud-infra/scripts/generate-change-metadata.sh @@ -42,8 +42,15 @@ function determine_dependency() { echo "Info : Processing change $DEPENDENT_CHANGE_ID" declare -a DEPENDENT_CHANGE_METADATA - readarray -t DEPENDENT_CHANGE_METADATA < <(curl -s "https://gerrit.nordix.org/changes/?q=$DEPENDENT_CHANGE_ID&o=CURRENT_REVISION" 2>&1 \ - | grep "project\|status\|current_revision\|ref\".*," | sed -e 's/\s//g' -e 's/,//g' -e 's/"//g'| cut -d: -f2) + # NOTE (cian): upgrades to Gerrit appear to change the output of the previously-used endpoint + # https://gerrit.nordix.org/changes/?q=$DEPENDENT_CHANGE_ID&o=CURRENT_REVISION so moving to + # gerrit SSH-based queries instead + GIT_BASE_SSH_CMD=$(echo "${GIT_BASE_SSH}" | sed -e 's#://# #g' | sed -e 's#:# -p #g') + readarray -t DEPENDENT_CHANGE_METADATA < <( + ${GIT_BASE_SSH_CMD} gerrit query --format=json change:${DEPENDENT_CHANGE_ID} --current-patch-set |\ + head -1 |\ + jq -r '[.project, .status, .currentPatchSet.revision, .currentPatchSet.ref] | join("\n")' + ) # NOTE (fdegir): check if the dependeny change exists # and ignore if it doesn't -- 2.25.1