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 a7122ab..19bfc4e 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 <LFID>"
# - infra public key on build server needs to be added to your users SSH
# Public Keys in OpenDaylight Gerrit
#
@@ -43,13 +42,25 @@
# GERRIT_PROJECT is in the form of opendaylight/<opendaylight-project>
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 <LFID>"
+ exit 1
+fi
opendaylight_remote_url="ssh://$username@$opendaylight_gerrit_base/$opendaylight_project"