Remove code duplication - single global rebase-jobs.sh script 32/2332/2
authorrobert.tomczyk <robert.tomczyk@est.tech>
Wed, 25 Sep 2019 08:31:57 +0000 (09:31 +0100)
committerRobert Tomczyk <robert.tomczyk@est.tech>
Wed, 25 Sep 2019 08:34:20 +0000 (08:34 +0000)
Change-Id: I8accc5038188a81d9ce79142a25072395508a98d

jjb/acumos/global-templates-acumos-rebase.yaml
jjb/acumos/rebase-jobs.sh [deleted file]
jjb/global/rebase-jobs.sh [changed mode: 0755->0644]
jjb/onap/global-templates-onap-rebase.yaml
jjb/onap/rebase-jobs.sh [deleted file]
jjb/opendaylight/global-templates-opendaylight-rebase.yaml
jjb/opendaylight/rebase-jobs.sh [deleted file]
jjb/opendev/global-templates-opendev-rebase.yaml
jjb/opendev/rebase-jobs.sh [deleted file]
jjb/oransc/global-templates-oran-rebase.yaml
jjb/oransc/rebase-jobs.sh [deleted file]

index 3d33b2fb21109a3bfb100ff65aed46e7ac9f6f72..d4c176d16d0c6bd72a2ed9b8954a9b2bd1ef3457 100644 (file)
@@ -42,7 +42,7 @@
 
     builders:
       - shell:
 
     builders:
       - shell:
-          !include-raw-escape: ./rebase-jobs.sh
+          !include-raw-escape: ../global/rebase-jobs.sh
 
     publishers:
       - notify-slack:
 
     publishers:
       - notify-slack:
diff --git a/jjb/acumos/rebase-jobs.sh b/jjb/acumos/rebase-jobs.sh
deleted file mode 100755 (executable)
index 41c2aa3..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-cd $WORKSPACE
-# Make sure the Nordix is set from Jenkins Job configuration
-# parameter: NORDIX_REMOTE and not from previous job execution
-if git remote | grep nordix > /dev/null ; then
-    git remote rm nordix
-fi
-# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
-# but it's executed as part of timer. In this case we will make sure that all
-# branches from remote are synced with Nordix Gerrit.
-if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
-    echo "-- Fetch all branches from Acumos for project: ${PROJECT} --"
-    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
-    for branch in ${REMOTE_BRANCHES}  ; do
-        git branch -f --track ${branch} origin/${branch}
-    done
-# The job was triggered by merge on Acumos. We will make sure that branch set
-# in GERRIT_BRANCH is in sync with Nordix Gerrit.
-else
-    echo "-- Fetch branch: ${GERRIT_BRANCH} from Acumos for project: ${PROJECT} --"
-    REMOTE_BRANCHES=${GERRIT_BRANCH}
-    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
-fi
-git fetch origin -v
-echo "-- Adding new remote $NORDIX_REMOTE for sync --"
-git remote add nordix $NORDIX_REMOTE
-git remote -v
-echo "-- Merging changes from Acumos remote branches to local branch: --"
-for branch in ${REMOTE_BRANCHES}  ; do
-    echo "------ Branch name: ${branch}"
-    git checkout ${branch} -q
-    git merge origin/${branch} --ff-only --stat
-done
-echo "-- Pushing changes to Nordix Gerrit --"
-git push nordix --all -v
-echo "--------------------------------------------------------------------"
old mode 100755 (executable)
new mode 100644 (file)
index b2f7737..f124691
@@ -4,17 +4,37 @@ set -o nounset
 set -o pipefail
 
 cd $WORKSPACE
 set -o pipefail
 
 cd $WORKSPACE
-echo "Checking out $BRANCH"
-git checkout $BRANCH -q
-git pull -q
-echo "Commit is"
-echo "-------------------------------------------"
-git show -s
-echo "-------------------------------------------"
-echo "Adding new remote $NORDIX_REMOTE for sync"
+# Make sure the Nordix is set from Jenkins Job configuration
+# parameter: NORDIX_REMOTE and not from previous job execution
+if git remote | grep nordix > /dev/null ; then
+    git remote rm nordix
+fi
+# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
+# but it's executed as part of timer. In this case we will make sure that all
+# branches from remote are synced with Nordix Gerrit.
+if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
+    echo "-- Fetch all ${PROJECT} branches from Gerrit upstream --"
+    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
+    for branch in ${REMOTE_BRANCHES}  ; do
+        git branch -f --track ${branch} origin/${branch}
+    done
+# The job was triggered by merge on upstream Gerrit. We will make sure that branch set
+# in GERRIT_BRANCH is in sync with Nordix Gerrit.
+else
+    echo "-- Fetch branch: ${GERRIT_BRANCH} for project: ${PROJECT} --"
+    REMOTE_BRANCHES=${GERRIT_BRANCH}
+    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
+fi
+git fetch origin -v
+echo "-- Adding new remote $NORDIX_REMOTE for sync --"
 git remote add nordix $NORDIX_REMOTE
 git remote add nordix $NORDIX_REMOTE
-echo "-------------------------------------------"
 git remote -v
 git remote -v
-echo "-------------------------------------------"
-echo "Pushing changes to Nordix branch $BRANCH"
-git push nordix $BRANCH
+echo "-- Merging changes from Gerrit upstream remote branches to local branch: --"
+for branch in ${REMOTE_BRANCHES}  ; do
+    echo "------ Branch name: ${branch}"
+    git checkout ${branch} -q -f
+    git merge origin/${branch} --ff-only --stat
+done
+echo "-- Pushing changes to Nordix Gerrit --"
+git push nordix --all -v
+echo "--------------------------------------------------------------------"
index acb47909ab76f8a5f5d073dc5702541226bc9846..723190a422a97191b0df803a752ad4e1ed5ac3b5 100644 (file)
@@ -42,7 +42,7 @@
 
     builders:
       - shell:
 
     builders:
       - shell:
-          !include-raw-escape: ./rebase-jobs.sh
+          !include-raw-escape: ../global/rebase-jobs.sh
 
     publishers:
       - notify-slack:
 
     publishers:
       - notify-slack:
diff --git a/jjb/onap/rebase-jobs.sh b/jjb/onap/rebase-jobs.sh
deleted file mode 100755 (executable)
index d8a9822..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-cd $WORKSPACE
-# Make sure the Nordix is set from Jenkins Job configuration
-# parameter: NORDIX_REMOTE and not from previous job execution
-if git remote | grep nordix > /dev/null ; then
-    git remote rm nordix
-fi
-# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
-# but it's executed as part of timer. In this case we will make sure that all
-# branches from remote are synced with Nordix Gerrit.
-if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
-    echo "-- Fetch all branches from ONAP for project: ${PROJECT} --"
-    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
-    for branch in ${REMOTE_BRANCHES}  ; do
-        git branch -f --track ${branch} origin/${branch}
-    done
-# The job was triggered by merge on ONAP Gerrit. We will make sure that branch set
-# in GERRIT_BRANCH is in sync with Nordix Gerrit.
-else
-    echo "-- Fetch branch: ${GERRIT_BRANCH} from ONAP for project: ${PROJECT} --"
-    REMOTE_BRANCHES=${GERRIT_BRANCH}
-    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
-fi
-git fetch origin -v
-echo "-- Adding new remote $NORDIX_REMOTE for sync --"
-git remote add nordix $NORDIX_REMOTE
-git remote -v
-echo "-- Merging changes from ONAP remote branches to local branch: --"
-for branch in ${REMOTE_BRANCHES}  ; do
-    echo "------ Branch name: ${branch}"
-    git checkout ${branch} -q -f
-    git merge origin/${branch} --ff-only --stat
-done
-echo "-- Pushing changes to Nordix Gerrit --"
-git push nordix --all -v
-echo "--------------------------------------------------------------------"
index 3c03959d84c1b5cea660e02f004350be42a489c9..71be8982f7e215ebaade5eadca1946135b369dcf 100644 (file)
@@ -42,7 +42,7 @@
 
     builders:
       - shell:
 
     builders:
       - shell:
-          !include-raw-escape: ./rebase-jobs.sh
+          !include-raw-escape: ../global/rebase-jobs.sh
 
     publishers:
       - notify-slack:
 
     publishers:
       - notify-slack:
diff --git a/jjb/opendaylight/rebase-jobs.sh b/jjb/opendaylight/rebase-jobs.sh
deleted file mode 100755 (executable)
index 8cec63a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-cd $WORKSPACE
-# Make sure the Nordix is set from Jenkins Job configuration
-# parameter: NORDIX_REMOTE and not from previous job execution
-if git remote | grep nordix > /dev/null ; then
-    git remote rm nordix
-fi
-# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
-# but it's executed as part of timer. In this case we will make sure that all
-# branches from remote are synced with Nordix Gerrit.
-if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
-    echo "-- Fetch all branches from OpenDaylight for project: ${PROJECT} --"
-    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
-    for branch in ${REMOTE_BRANCHES}  ; do
-        git branch -f --track ${branch} origin/${branch}
-    done
-# The job was triggered by merge on OpenDaylight. We will make sure that branch set
-# in GERRIT_BRANCH is in sync with Nordix Gerrit.
-else
-    echo "-- Fetch branch: ${GERRIT_BRANCH} from OpenDaylight for project: ${PROJECT} --"
-    REMOTE_BRANCHES=${GERRIT_BRANCH}
-    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
-fi
-git fetch origin -v
-echo "-- Adding new remote $NORDIX_REMOTE for sync --"
-git remote add nordix $NORDIX_REMOTE
-git remote -v
-echo "-- Merging changes from OpenDaylight remote branches to local branch: --"
-for branch in ${REMOTE_BRANCHES}  ; do
-    echo "------ Branch name: ${branch}"
-    git checkout ${branch} -q
-    git merge origin/${branch} --ff-only --stat
-done
-echo "-- Pushing changes to Nordix Gerrit --"
-git push nordix --all -v
-echo "--------------------------------------------------------------------"
index cadfefd57e42ef604f004de52e6fb588aae14218..c8784ae2337cf62aa2d7d6fcaf6e0694d659741b 100644 (file)
@@ -42,7 +42,7 @@
 
     builders:
       - shell:
 
     builders:
       - shell:
-          !include-raw-escape: ./rebase-jobs.sh
+          !include-raw-escape: ../global/rebase-jobs.sh
 
     publishers:
       - notify-slack:
 
     publishers:
       - notify-slack:
diff --git a/jjb/opendev/rebase-jobs.sh b/jjb/opendev/rebase-jobs.sh
deleted file mode 100755 (executable)
index 90b84c2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-cd $WORKSPACE
-# Make sure the Nordix is set from Jenkins Job configuration
-# parameter: NORDIX_REMOTE and not from previous job execution
-if git remote | grep nordix > /dev/null ; then
-    git remote rm nordix
-fi
-# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
-# but it's executed as part of timer. In this case we will make sure that all
-# branches from remote are synced with Nordix Gerrit.
-if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
-    echo "-- Fetch all branches from OpenDev for project: ${PROJECT} --"
-    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
-    for branch in ${REMOTE_BRANCHES}  ; do
-        git branch -f --track ${branch} origin/${branch}
-    done
-# The job was triggered by merge on OpenDev. We will make sure that branch set
-# in GERRIT_BRANCH is in sync with Nordix Gerrit.
-else
-    echo "-- Fetch branch: ${GERRIT_BRANCH} from OpenDev for project: ${PROJECT} --"
-    REMOTE_BRANCHES=${GERRIT_BRANCH}
-    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
-fi
-git fetch origin -v
-echo "-- Adding new remote $NORDIX_REMOTE for sync --"
-git remote add nordix $NORDIX_REMOTE
-git remote -v
-echo "-- Merging changes from OpenDev remote branches to local branch: --"
-for branch in ${REMOTE_BRANCHES}  ; do
-    echo "------ Branch name: ${branch}"
-    git checkout ${branch} -q
-    git merge origin/${branch} --ff-only --stat
-done
-echo "-- Pushing changes to Nordix Gerrit --"
-git push nordix --all -v
-echo "--------------------------------------------------------------------"
index 60175bf4a60853d5d56fa4f3dc329a48593f1157..f1e909a02b6f9f4caea836dc6c2594f126a8f0e2 100644 (file)
@@ -39,7 +39,7 @@
 
     builders:
       - shell:
 
     builders:
       - shell:
-          !include-raw-escape: ./rebase-jobs.sh
+          !include-raw-escape: ../global/rebase-jobs.sh
 
     publishers:
       - notify-slack:
 
     publishers:
       - notify-slack:
diff --git a/jjb/oransc/rebase-jobs.sh b/jjb/oransc/rebase-jobs.sh
deleted file mode 100755 (executable)
index d5c90e4..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o nounset
-set -o pipefail
-
-cd $WORKSPACE
-# Make sure the Nordix is set from Jenkins Job configuration
-# parameter: NORDIX_REMOTE and not from previous job execution
-if git remote | grep nordix > /dev/null ; then
-    git remote rm nordix
-fi
-# When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
-# but it's executed as part of timer. In this case we will make sure that all
-# branches from remote are synced with Nordix Gerrit.
-if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
-    echo "-- Fetch all branches from ORAN Gerrit for project: ${PROJECT} --"
-    REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
-    for branch in ${REMOTE_BRANCHES}  ; do
-        git branch -f --track ${branch} origin/${branch}
-    done
-# The job was triggered by merge on ORAN Gerrit. We will make sure that branch set
-# in GERRIT_BRANCH is in sync with Nordix Gerrit.
-else
-    echo "-- Fetch branch: ${GERRIT_BRANCH} from ORAN Gerrit for project: ${PROJECT} --"
-    REMOTE_BRANCHES=${GERRIT_BRANCH}
-    git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
-fi
-git fetch origin -v
-echo "-- Adding new remote $NORDIX_REMOTE for sync --"
-git remote add nordix $NORDIX_REMOTE
-git remote -v
-echo "-- Merging changes from ORAN remote branches to local branch: --"
-for branch in ${REMOTE_BRANCHES}  ; do
-    echo "------ Branch name: ${branch}"
-    git checkout ${branch} -q -f
-    git merge origin/${branch} --ff-only --stat
-done
-echo "-- Pushing changes to Nordix Gerrit --"
-git push nordix --all -v
-echo "--------------------------------------------------------------------"