sandbox: Pass GERRIT parameters and create merge jobs 73/16573/2
authorFatih Degirmenci <fatih.degirmenci@ericsson.com>
Thu, 7 Jul 2016 11:43:15 +0000 (13:43 +0200)
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>
Thu, 7 Jul 2016 20:04:19 +0000 (22:04 +0200)
Change-Id: Idf4f87043929ab1c0e97a60899a116c745386a96
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
jjb/sandbox/basic.sh [new file with mode: 0755]
jjb/sandbox/build.sh [new file with mode: 0755]
jjb/sandbox/deploy.sh [new file with mode: 0755]
jjb/sandbox/merge.sh [new file with mode: 0755]
jjb/sandbox/promote.sh [new file with mode: 0755]
jjb/sandbox/sandbox-merge-jobs.yml [new file with mode: 0644]
jjb/sandbox/sandbox-verify-jobs.yml
jjb/sandbox/test.sh [new file with mode: 0755]
jjb/sandbox/verify.sh [new file with mode: 0755]

diff --git a/jjb/sandbox/basic.sh b/jjb/sandbox/basic.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/build.sh b/jjb/sandbox/build.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/deploy.sh b/jjb/sandbox/deploy.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/merge.sh b/jjb/sandbox/merge.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/promote.sh b/jjb/sandbox/promote.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/sandbox-merge-jobs.yml b/jjb/sandbox/sandbox-merge-jobs.yml
new file mode 100644 (file)
index 0000000..32f75e6
--- /dev/null
@@ -0,0 +1,159 @@
+- project:
+    name: 'sandbox-merge-jobs'
+
+    project: 'sandbox'
+
+    installer: 'sandbox'
+
+    stream:
+        - master:
+            branch: '{stream}'
+            gs-pathname: ''
+
+# what are the verification activities we do for this installer
+    activity:
+        - 'basic'
+        - 'build'
+        - 'promote'
+
+    jobs:
+        - 'sandbox-merge-{stream}'
+        - 'sandbox-merge-{activity}-{stream}'
+
+- job-template:
+    name: 'sandbox-merge-{stream}'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - 'opnfv-build-ubuntu-defaults'
+
+    wrappers:
+        - ssh-agent-credentials:
+            users:
+                - '{ssh-credentials}'
+        - timeout:
+            timeout: 360
+            fail: true
+
+    triggers:
+        - gerrit:
+            trigger-on:
+                - change-merged-event
+                - comment-added-contains-event:
+                    comment-contains-value: 'remerge'
+            projects:
+              - project-compare-type: 'ANT'
+                project-pattern: '{project}'
+                branches:
+                    - branch-compare-type: 'ANT'
+                      branch-pattern: '**/{branch}'
+                forbidden-file-paths:
+                  - compare-type: ANT
+                    pattern: 'docs/**'
+            readable-message: true
+
+    builders:
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - '{project}-merge-builder'
+        - trigger-builds:
+            - project: 'sandbox-merge-basic-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+              block: true
+        - trigger-builds:
+            - project: 'sandbox-merge-build-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+              block: true
+        - trigger-builds:
+            - project: 'sandbox-merge-promote-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+              block: true
+
+- job-template:
+    name: 'sandbox-merge-{activity}-{stream}'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: ''
+            choosing-strategy: 'default'
+
+    wrappers:
+        - ssh-agent-credentials:
+            users:
+                - '{ssh-credentials}'
+        - timeout:
+            timeout: 360
+            fail: true
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - '{installer}-defaults'
+        - '{project}-merge-{activity}-parameter'
+
+    builders:
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - '{project}-merge-{activity}-builder'
+
+#####################################
+# parameter builders
+#####################################
+- parameter:
+    name: 'sandbox-merge-basic-parameter'
+    parameters:
+        - 'opnfv-build-ubuntu-defaults'
+
+- parameter:
+    name: 'sandbox-merge-build-parameter'
+    parameters:
+        - 'opnfv-build-ubuntu-defaults'
+
+- parameter:
+    name: 'sandbox-merge-promote-parameter'
+    parameters:
+        - 'opnfv-build-centos-defaults'
+#####################################
+# builder builders
+#####################################
+- builder:
+    name: 'sandbox-merge-builder'
+    builders:
+        - shell:
+            !include-raw: ./merge.sh
+
+- builder:
+    name: 'sandbox-merge-basic-builder'
+    builders:
+        - shell:
+            !include-raw: ./basic.sh
+
+- builder:
+    name: 'sandbox-merge-build-builder'
+    builders:
+        - shell:
+            !include-raw: ./build.sh
+
+- builder:
+    name: 'sandbox-merge-promote-builder'
+    builders:
+        - shell:
+            !include-raw: ./promote.sh
index b1e8e93..0572440 100644 (file)
 
     builders:
         - description-setter:
-            description: "POD: $NODE_NAME"
+            description: "Built on $NODE_NAME"
         - '{project}-verify-builder'
         - trigger-builds:
             - project: 'sandbox-verify-basic-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
               block: true
         - trigger-builds:
             - project: 'sandbox-verify-build-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
               block: true
         - trigger-builds:
             - project: 'sandbox-verify-deploy-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
               block: true
         - trigger-builds:
             - project: 'sandbox-verify-test-{stream}'
+              current-parameters: false
+              predefined-parameters:
+                GERRIT_BRANCH=$GERRIT_BRANCH
+                GERRIT_REFSPEC=$GERRIT_REFSPEC
+                GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
               block: true
 
 - job-template:
 
     builders:
         - description-setter:
-            description: "POD: $NODE_NAME"
+            description: "Built on $NODE_NAME"
         - '{project}-verify-{activity}-builder'
 
 #####################################
 - builder:
     name: 'sandbox-verify-builder'
     builders:
-        - shell: |
-            #!/bin/bash
-
-            # this is the builder for the parent/upstream job which we do nothing
-            cd $WORKSPACE
-            echo
-            echo "Commit Message is"
-            echo "-------------------------------------"
-            echo $GERRIT_CHANGE_COMMIT_MESSAGE
-            echo "-------------------------------------"
-            echo
-            echo "Repo contents"
-            echo "-------------------------------------"
-            ls -al
-            echo "-------------------------------------"
-            echo
-            echo "Changed files are"
-            echo "-------------------------------------"
-            git diff origin/master --name-only
-            echo "-------------------------------------"
-            echo
-            echo "Change introduced"
-            echo "-------------------------------------"
-            git diff origin/master
-            echo "-------------------------------------"
+        - shell:
+            !include-raw: ./verify.sh
 
 - builder:
     name: 'sandbox-verify-basic-builder'
     builders:
-        - shell: |
-            #!/bin/bash
-
-            # this is where we check the commit message, unit test, etc.
-            cd $WORKSPACE
-            echo
-            echo "Commit Message is"
-            echo "-------------------------------------"
-            echo $GERRIT_CHANGE_COMMIT_MESSAGE
-            echo "-------------------------------------"
-            echo
-            echo "Repo contents"
-            echo "-------------------------------------"
-            ls -al
-            echo "-------------------------------------"
-            echo
-            echo "Changed files are"
-            echo "-------------------------------------"
-            git diff origin/master --name-only
-            echo "-------------------------------------"
-            echo
-            echo "Change introduced"
-            echo "-------------------------------------"
-            git diff origin/master
-            echo "-------------------------------------"
+        - shell:
+            !include-raw: ./basic.sh
 
 - builder:
     name: 'sandbox-verify-build-builder'
     builders:
-        - shell: |
-            #!/bin/bash
-
-            # this is where we do the build
-            cd $WORKSPACE
-            echo
-            echo "Commit Message is"
-            echo "-------------------------------------"
-            echo $GERRIT_CHANGE_COMMIT_MESSAGE
-            echo "-------------------------------------"
-            echo
-            echo "Repo contents"
-            echo "-------------------------------------"
-            ls -al
-            echo "-------------------------------------"
-            echo
-            echo "Changed files are"
-            echo "-------------------------------------"
-            git diff origin/master --name-only
-            echo "-------------------------------------"
-            echo
-            echo "Change introduced"
-            echo "-------------------------------------"
-            git diff origin/master
-            echo "-------------------------------------"
+        - shell:
+            !include-raw: ./build.sh
 
 - builder:
     name: 'sandbox-verify-deploy-builder'
     builders:
-        - shell: |
-            #!/bin/bash
-
-            # this is where we start the virtual deployment
-            cd $WORKSPACE
-            echo
-            echo "Commit Message is"
-            echo "-------------------------------------"
-            echo $GERRIT_CHANGE_COMMIT_MESSAGE
-            echo "-------------------------------------"
-            echo
-            echo "Repo contents"
-            echo "-------------------------------------"
-            ls -al
-            echo "-------------------------------------"
-            echo
-            echo "Changed files are"
-            echo "-------------------------------------"
-            git diff origin/master --name-only
-            echo "-------------------------------------"
-            echo
-            echo "Change introduced"
-            echo "-------------------------------------"
-            git diff origin/master
-            echo "-------------------------------------"
+        - shell:
+            !include-raw: ./deploy.sh
 
 - builder:
     name: 'sandbox-verify-test-builder'
     builders:
-        - shell: |
-            #!/bin/bash
-
-            # this is where we do functest smoketest
-            cd $WORKSPACE
-            echo
-            echo "Commit Message is"
-            echo "-------------------------------------"
-            echo $GERRIT_CHANGE_COMMIT_MESSAGE
-            echo "-------------------------------------"
-            echo
-            echo "Repo contents"
-            echo "-------------------------------------"
-            ls -al
-            echo "-------------------------------------"
-            echo
-            echo "Changed files are"
-            echo "-------------------------------------"
-            git diff origin/master --name-only
-            echo "-------------------------------------"
-            echo
-            echo "Change introduced"
-            echo "-------------------------------------"
-            git diff origin/master
-            echo "-------------------------------------"
+        - shell:
+            !include-raw: ./test.sh
diff --git a/jjb/sandbox/test.sh b/jjb/sandbox/test.sh
new file mode 100755 (executable)
index 0000000..2f9be27
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+#set -o errexit
+#set -o nounset
+#set -o pipefail
+
+# get the job type
+# we only support verify, merge, daily and weekly jobs
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Running as part of verify job"
+        ;;
+    merge)
+        echo "Running as part of merge job"
+        ;;
+    daily)
+        echo "Running as part of daily job"
+        ;;
+    weekly)
+        echo "Running as part of weekly job"
+        ;;
+    *)
+        echo "Job type $JOB_TYPE is not supported!"
+        exit 1
+esac
+
+# this just shows we can get the patch/commit information
+# no matter what job we are executed by
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"
diff --git a/jjb/sandbox/verify.sh b/jjb/sandbox/verify.sh
new file mode 100755 (executable)
index 0000000..f62d2b9
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# this is where we check the commit message, unit test, etc.
+cd $WORKSPACE
+echo
+echo "Commit Message is"
+echo "-------------------------------------"
+git log --format=%B -n 1 $(git rev-parse HEAD)
+echo "-------------------------------------"
+echo
+echo "Repo contents"
+echo "-------------------------------------"
+ls -al
+echo "-------------------------------------"
+echo
+echo "Changed files are"
+echo "-------------------------------------"
+git diff origin/master --name-only
+echo "-------------------------------------"
+echo
+echo "Change introduced"
+echo "-------------------------------------"
+git diff origin/master
+echo "-------------------------------------"
+echo
+echo "git show"
+echo "-------------------------------------"
+git show
+echo "-------------------------------------"