X-Git-Url: https://gerrit.nordix.org/gitweb?a=blobdiff_plain;f=jjb%2Fopendev%2Fpush-upstream-jobs.sh;h=7f2a696d24cea49d4ec1d9fd6de7e175e5817e4d;hb=364db40009d328c41c9b17a42434ce160f132528;hp=83c858d9901906946dc2bb7e80e3b86703200d3d;hpb=81ffa8ff9c4f9477a362f6b89eb308e6ffc33f03;p=infra%2Fcicd.git diff --git a/jjb/opendev/push-upstream-jobs.sh b/jjb/opendev/push-upstream-jobs.sh index 83c858d9..7f2a696d 100755 --- a/jjb/opendev/push-upstream-jobs.sh +++ b/jjb/opendev/push-upstream-jobs.sh @@ -46,13 +46,10 @@ opendev_project=$(echo "$GERRIT_PROJECT" | cut -d/ -f2- ) # Nordix Gerrit can map the email address of the user pushed the change to # the review to the Gerrit username of the accound in Nordix Gerrit. This # should match with the Gerrit username in the OpenDev Gerrit. -# TODO(gibi): parse the json propely if there are tools (e.g. jq) available on -# the jenkins slave username=$( curl -s -H 'Accept: application/json' \ "$nordix_gerrit_rest/accounts/?q=email:$GERRIT_EVENT_ACCOUNT_EMAIL&o=DETAILS" \ - | tee /dev/stderr \ - | sed -n 's/^.*"username":"\(\S*\)".*$/\1/p') + | tee /dev/stderr | tail -1 | jq -r '.[0].username') opendev_remote_url="ssh://$username@$opendev_gerrit_base/$opendev_project" @@ -61,9 +58,9 @@ opendev_remote_url="ssh://$username@$opendev_gerrit_base/$opendev_project" # GERRIT_TOPIC is the rest of the refspec after GERRIT_BRANCH when the topic # is set for the change. if [ -z "${GERRIT_TOPIC:-}" ] ; then - refspec="$commit_hash:refs/for/$GERRIT_BRANCH" + refspec="${commit_hash}:refs/for/${GERRIT_BRANCH}" else - refspec="$commit_hash:refs/for/$GERRIT_BRANCH/$GERRIT_TOPIC" + refspec="${commit_hash}:refs/for/${GERRIT_BRANCH}%topic=${GERRIT_TOPIC}" fi echo >&2 "Pushing to OpenDev" @@ -81,4 +78,3 @@ push_result=${PIPESTATUS[0]} if [ $push_result -ne 0 ]; then grep '(no new changes)' push_result.txt fi -