From: afenner Date: Fri, 9 Aug 2019 08:18:42 +0000 (+0100) Subject: Change where opendaylight username read from on commit X-Git-Url: https://gerrit.nordix.org/gitweb?a=commitdiff_plain;ds=inline;h=9610398296d99e9e6abeeb98a1ab1c3e950b239f;p=infra%2Fcicd.git Change where opendaylight username read from on commit Change-Id: Iafd68478823725e3c81ccc34870ccf0e4ce1a5b3 --- diff --git a/jjb/opendaylight/push-upstream-jobs.sh b/jjb/opendaylight/push-upstream-jobs.sh index a7122ab8..19bfc4ed 100755 --- a/jjb/opendaylight/push-upstream-jobs.sh +++ b/jjb/opendaylight/push-upstream-jobs.sh @@ -23,8 +23,7 @@ # and push it, and all its ancestor commit till $GERRIT_BRANCH, to OpenDaylight # Gerrit. # Pre-requisites for script to run successfully: -# - The Gerrit username in Nordix needs to match with the Gerrit username in -# OpenDaylight +# - Author name in Nordix Gerrit equals LFID i.e. need to run "git config --global user.name " # - infra public key on build server needs to be added to your users SSH # Public Keys in OpenDaylight Gerrit # @@ -43,13 +42,25 @@ commit_hash="$GERRIT_PATCHSET_REVISION" # GERRIT_PROJECT is in the form of opendaylight/ opendaylight_project=$(echo "$GERRIT_PROJECT" | cut -d/ -f2- ) +# original way to get user name based on nordix id replaced by method below # Nordix Gerrit can map the email address of the user pushed the change to # the review to the Gerrit username of the account in Nordix Gerrit. This # should match with the Gerrit username in the OpenDaylight Gerrit. -username=$( - curl -s -H 'Accept: application/json' \ - "$nordix_gerrit_rest/accounts/?q=email:$GERRIT_EVENT_ACCOUNT_EMAIL&o=DETAILS" \ - | tee /dev/stderr | tail -1 | jq -r '.[0].username') +#username=$( +# curl -s -H 'Accept: application/json' \ +# "$nordix_gerrit_rest/accounts/?q=email:$GERRIT_EVENT_ACCOUNT_EMAIL&o=DETAILS" \ +# | tee /dev/stderr | tail -1 | jq -r '.[0].username') + +# read user name from the commit details which allows nordix user name to be different to lfid +username=$(git show -s --pretty=%an) + +pattern=" " +if [[ "$username" =~ $pattern ]] +then + echo "Incorrect username, use Linux Foundation ID as git user.name when pushing to Nordix" + echo "Use command git config --global user.name " + exit 1 +fi opendaylight_remote_url="ssh://$username@$opendaylight_gerrit_base/$opendaylight_project"