From: robert.tomczyk Date: Fri, 21 Jun 2019 16:45:34 +0000 (+0100) Subject: OPENDEV: Parse json using jq tool X-Git-Url: https://gerrit.nordix.org/gitweb?a=commitdiff_plain;h=b113852c4b3d4f1bd9616ad904e767c608a6012d;p=infra%2Fcicd.git OPENDEV: Parse json using jq tool Change-Id: I864a0a229728337246a18aa28ddcff57481f1e50 --- diff --git a/jjb/opendev/push-upstream-jobs.sh b/jjb/opendev/push-upstream-jobs.sh index 83c858d99..0e1326f93 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" @@ -81,4 +78,3 @@ push_result=${PIPESTATUS[0]} if [ $push_result -ne 0 ]; then grep '(no new changes)' push_result.txt fi -