X-Git-Url: https://gerrit.nordix.org/gitweb?a=blobdiff_plain;f=jjb%2Fglobal%2Fpush-upstream-jobs.sh;h=49af36e76eeb92801afa401140a22f080e236d9b;hb=ec267334bac7beb410fd7e219c71d6fa95453212;hp=3eedac2cb1329c42697df990e8b0399b09d6ed80;hpb=f661d05a8b0c51f95e443e9066a3f70965a203db;p=infra%2Fcicd.git diff --git a/jjb/global/push-upstream-jobs.sh b/jjb/global/push-upstream-jobs.sh index 3eedac2c..49af36e7 100755 --- a/jjb/global/push-upstream-jobs.sh +++ b/jjb/global/push-upstream-jobs.sh @@ -24,7 +24,6 @@ # - 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 ONAP Gerrit # -set -o errexit set -o nounset set -o pipefail @@ -46,22 +45,32 @@ git config user.email $(git show -s --pretty=%ae) git config user.name $username echo "Checking out branch on master with new changes" -git reset HEAD~1 -git checkout -b delivery_branch origin/master +git reset HEAD~1 --soft +git checkout -b delivery_branch origin/$BRANCH -echo '[remote "upstream"]' >> $WORKSPACE/.git/config -echo " url = ssh://$username@gerrit.onap.org:29418/$project.git" >> $WORKSPACE/.git/config -echo " fetch = +refs/heads/*:refs/remotes/upstream/*" >> $WORKSPACE/.git/config +git config --get remote.upstream.url +retVal=$? + +if [[ $retVal -eq 0 ]] +then + git remote rm upstream + git remote add upstream "ssh://$username@gerrit.onap.org:29418/$project.git" +else + git remote add upstream "ssh://$username@gerrit.onap.org:29418/$project.git" +fi echo "Committing changes and pushing upstream" git commit -as -m "$message" -git push upstream HEAD:refs/for/master +git push upstream HEAD:refs/for/$BRANCH -retVal=$? -if [[ $retVal -eq 0 ]] +retVal1=$? +if [[ $retVal1 -eq 0 ]] then echo "Push upstream to ONAP succeeded" else echo "Push upstream to ONAP failed" exit 2 fi + +git checkout $BRANCH +git branch -D delivery_branch