From 7407e9027d6300beca383cdda9c09f1cfa3849ca Mon Sep 17 00:00:00 2001
From: Shweta Shrivastava <s.shrivastava@northeastern.edu>
Date: Fri, 23 Apr 2021 14:22:50 -0500
Subject: [PATCH] Changes to update pipeline status on Gitlab MR page

---
 ci-scripts/Jenkinsfile-NU-Col-CI | 38 +++++++++++++++++++-------------
 ci-scripts/Jenkinsfile-NU-main   | 26 ++++++++++++----------
 2 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/ci-scripts/Jenkinsfile-NU-Col-CI b/ci-scripts/Jenkinsfile-NU-Col-CI
index ae6a9728450..121e04a3cf6 100644
--- a/ci-scripts/Jenkinsfile-NU-Col-CI
+++ b/ci-scripts/Jenkinsfile-NU-Col-CI
@@ -55,14 +55,16 @@ pipeline {
         stage ("print latest commit info") {
             steps {
                 script {
-                    echo "Building on: "
-                    echo "  Repository -- ${GIT_URL}"
-                    echo "  Branch -- ${GIT_BRANCH}"
-                    echo "  Commit -- ${GIT_COMMIT}"
-                    echo "ENV eNB_mergeRequest: ${params.eNB_mergeRequest}"
-                    echo "ENV eNB_Repository: ${params.eNB_Repository}"
-                    echo "ENV source branch: ${params.eNB_Branch}"
-                    echo "ENV target branch: ${params.eNB_TargetBranch}"
+                    gitlabCommitStatus(name: "Print latest commit info") {
+                        echo "Building on: "
+                        echo "  Repository -- ${GIT_URL}"
+                        echo "  Branch -- ${GIT_BRANCH}"
+                        echo "  Commit -- ${GIT_COMMIT}"
+                        echo "ENV eNB_mergeRequest: ${params.eNB_mergeRequest}"
+                        echo "ENV eNB_Repository: ${params.eNB_Repository}"
+                        echo "ENV source branch: ${params.eNB_Branch}"
+                        echo "ENV target branch: ${params.eNB_TargetBranch}"
+                    }
                 }
             }
         }
@@ -70,16 +72,20 @@ pipeline {
         stage ('Clone Ansible toolchain') {
             steps {
                 script {
-                    sh "git clone https://gitlab.com/shweta.shrivastava/colosseum-cm.git"
+                    gitlabCommitStatus(name: "Clone Ansible scripts") {
+                        sh "git clone https://gitlab.com/shweta.shrivastava/colosseum-cm.git"
+                    }
                 }
             }
         }
-        stage ('Set up Ansible toolchain') {
+        stage ('Configure Ansible toolchain') {
             steps {
                 script {
-                    dir ('colosseum-cm') {
-                        sh "git checkout oai-ci"
-                        sh "./bootstrap.sh ${GIT_URL} ${params.eNB_Branch} ${GIT_COMMIT}"
+                    gitlabCommitStatus(name: "Configure Ansible toolchain") {
+                        dir ('colosseum-cm') {
+                            sh "git checkout oai-ci"
+                            sh "./bootstrap.sh ${GIT_URL} ${params.eNB_Branch} ${GIT_COMMIT}"
+                        }
                     }
                 }
             }
@@ -87,8 +93,10 @@ pipeline {
         stage ('Run Ansible toolchain') {
             steps {
                 script {
-                    dir ('colosseum-cm/ansible') {
-                        sh "ansible-playbook oai.yml"
+                    gitlabCommitStatus(name: "Run Ansible toolchain") {
+                        dir ('colosseum-cm/ansible') {
+                            sh "ansible-playbook oai.yml"
+                        }
                     }
                 }
             }
diff --git a/ci-scripts/Jenkinsfile-NU-main b/ci-scripts/Jenkinsfile-NU-main
index 4daab62663d..77fa9856a08 100644
--- a/ci-scripts/Jenkinsfile-NU-main
+++ b/ci-scripts/Jenkinsfile-NU-main
@@ -57,18 +57,20 @@ pipeline {
     stages {
         stage ("print latest commit info") {
             steps {
-        	    script {
-        	        echo "Building on: "
-        	        echo "  Repository -- ${GIT_URL}"
-        	        echo "  Branch -- ${GIT_BRANCH}"
-                    echo "  Commit -- ${GIT_COMMIT}"
-                    //sh 'printenv'
-                    echo "ENV request type: ${env.gitlabMergeRequestIid}"
-                    echo "ENV action type: ${env.gitlabActionType}"
-                    echo "ENV branch: ${env.gitlabBranch}"
-                    echo "ENV source branch: ${env.gitlabSourceBranch}"
-                    echo "ENV target branch: ${env.gitlabTargetBranch}"
-        	    }
+                script {
+                    gitlabCommitStatus(name: "Print latest commit info") {
+                        echo "Building on: "
+                        echo "  Repository -- ${GIT_URL}"
+                        echo "  Branch -- ${GIT_BRANCH}"
+                        echo "  Commit -- ${GIT_COMMIT}"
+                        //sh 'printenv'
+                        echo "ENV request type: ${env.gitlabMergeRequestIid}"
+                        echo "ENV action type: ${env.gitlabActionType}"
+                        echo "ENV branch: ${env.gitlabBranch}"
+                        echo "ENV source branch: ${env.gitlabSourceBranch}"
+                        echo "ENV target branch: ${env.gitlabTargetBranch}"
+                    }
+                }
             }
         }
 //         stage ("Verify Parameters") {
-- 
GitLab