test-boris-Jenkinsfile 19.1 KB
Newer Older
Boris Djalal's avatar
Boris Djalal committed
1

Boris Djalal's avatar
Boris Djalal committed
2
#!/bin/groovy
Boris Djalal's avatar
Boris Djalal committed
3
/*
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1  (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
*      contact@openairinterface.org
*/
Boris Djalal's avatar
Boris Djalal committed
23

Boris Djalal's avatar
Save  
Boris Djalal committed
24

Boris Djalal's avatar
test  
Boris Djalal committed
25 26 27
// Abstraction function to send social media messages:
// like on Slack or Mattermost
def sendSocialMediaMessage(pipeChannel, pipeColor, pipeMessage) {
Boris Djalal's avatar
Boris Djalal committed
28 29 30 31 32
    if (params.pipelineUsesSlack != null) {
        if (params.pipelineUsesSlack) {
            slackSend channel: pipeChannel, color: pipeColor, message: pipeMessage
        }
    }
Boris Djalal's avatar
test  
Boris Djalal committed
33 34 35
}


Boris Djalal's avatar
Save  
Boris Djalal committed
36 37 38
// Location of the test XML file to be run
def testXMLFile = params.pythonTestXmlFile
def mainPythonAllXmlFiles = ""
Boris Djalal's avatar
Test  
Boris Djalal committed
39
def BUILD_STAGE_STATUS = true
Boris Djalal's avatar
Save  
Boris Djalal committed
40

Boris Djalal's avatar
Boris Djalal committed
41 42 43 44 45 46 47
// Terminate Status
def termUE = 0
def termENB = 1
def termStatusArray = new Boolean[2]
termStatusArray[termUE] = false
termStatusArray[termENB] = false

Boris Djalal's avatar
Save  
Boris Djalal committed
48 49 50 51 52 53
// Global Parameters.
def eNB_Repository
def eNB_Branch
def eNB_CommitID
def eNB_AllowMergeRequestProcess = false
def eNB_TargetBranch
Boris Djalal's avatar
Save  
Boris Djalal committed
54
def PROJECT_NAME = "test-boris"
Boris Djalal's avatar
Boris Djalal committed
55 56
def GIT_COMMIT_AUTHOR
def GIT_COMMIT_EMAIL
Boris Djalal's avatar
Boris Djalal committed
57
// Global Parameters not to break the main.py command line and code.
Boris Djalal's avatar
Save  
Boris Djalal committed
58
def ADB_IPAddress = "none"
Boris Djalal's avatar
Boris Djalal committed
59
def ADB_Username = "none"
Boris Djalal's avatar
Save  
Boris Djalal committed
60 61
def ADB_Password = "none"
def EPC_IPAddress = "none"
Boris Djalal's avatar
Save  
Boris Djalal committed
62 63
def EPC_Username = "none"
def EPC_Password = "none"
Boris Djalal's avatar
Boris Djalal committed
64 65


Boris Djalal's avatar
Save  
Boris Djalal committed
66

Boris Djalal's avatar
Boris Djalal committed
67
pipeline {
Boris Djalal's avatar
Boris Djalal committed
68 69
    agent {
        label pythonExecutor 
Boris Djalal's avatar
Boris Djalal committed
70
    }
Boris Djalal's avatar
Boris Djalal committed
71 72 73 74 75
    options {
        disableConcurrentBuilds()
        timestamps()
        gitLabConnection('OAI GitLab')
        ansiColor('xterm')
76
}
Boris Djalal's avatar
test  
Boris Djalal committed
77

Boris Djalal's avatar
Boris Djalal committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    stages {
        stage ('Retrieve latest from branch') {
            steps {
	        script {
	            checkout([$class: 'GitSCM', branches: [[name: '*/gNB-nrUE-USRP']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://gitlab.eurecom.fr/oai/openairinterface5g.git']]])
	            sh "git clean -x -d -ff"
	            sh "git log -n1"
	        }
            }
        }
        stage ("print latest commit info") {
            steps {
        	    script {
        	        echo "Building on: "
        	        echo "  Repository -- ${GIT_URL}"
        	        echo "  Branch -- ${GIT_BRANCH}"
        	        echo "  Commit -- ${GIT_COMMIT}"
        	        sh "git log -n1"
        	        //eNB_Repository = ${GIT_URL}
        	    }
            }
        }
        stage ("Verify Parameters") {
            steps {
                script {
                    JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"'
                    JOB_TIMESTAMP = JOB_TIMESTAMP.trim()
Boris Djalal's avatar
Save  
Boris Djalal committed
105

Boris Djalal's avatar
Boris Djalal committed
106 107
                    echo '\u2705 \u001B[32mVerify Parameters\u001B[0m'
                    def allParametersPresent = true
Boris Djalal's avatar
Boris Djalal committed
108

Boris Djalal's avatar
Boris Djalal committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
                    // It is already too late to check it
                    if (params.pythonExecutor != null) {
                       echo "eNB CI executor node  :   ${pythonExecutor}"
                    }
                    if (params.eNB_Repository == null) {
                        eNB_Repository = GIT_URL 
                    } else {
                        eNB_Repository = params.eNB_Repository
                    }
                    echo "eNB_Repository = ${eNB_Repository}"
                    if (params.eNB_Branch== null) {
                        eNB_Branch = GIT_BRANCH
                    } else {
                        eNB_Branch = params.eNB_Branch
                    }
                    echo "eNB_Branch = ${eNB_Branch}"
                    if (params.eNB_CommitID == null) {
                        eNB_CommitID = GIT_COMMIT 
                    } else {
                        eNB_CommitID = params.eNB_CommitID
                    }
                    echo "eNB_CommitID = ${eNB_CommitID}"
                    // If not present picking a default XML file
                    if (params.pythonTestXmlFile == null) {
                        // picking default
                        testXMLFile = 'xml_files/gnb_usrp_build.xml'
                        echo "Test XML file(default):   ${testXMLFile}"
                        mainPythonAllXmlFiles += "--XMLTestFile=" + testXMLFile + " "
                    } else {
                        String[] myXmlTestSuite = testXMLFile.split("\\r?\\n")
                        for (xmlFile in myXmlTestSuite) {
                            if (fileExists("ci-scripts/" + xmlFile)) {
                        	mainPythonAllXmlFiles += "--XMLTestFile=" + xmlFile + " "
                        	echo "Test XML file         :   ${xmlFile}"
                            }
                        }
                    }
                    // If not present picking a default Stage Name
                    if (params.pipelineTestStageName == null) {
                        // picking default
                        testStageName = 'Template Test Stage'
                    }
                    echo "params.eNB_IPAddress = ${params.eNB_IPAddress}"
                    if (params.eNB_IPAddress == null) {
                        allParametersPresent = false
                    }
                    echo "params.UE_IPAddress = ${params.UE_IPAddress}"
                    if (params.UE_IPAddress == null) {
                        allParametersPresent = false
                    }
                    echo "params.eNB_SourceCodePath = ${params.eNB_SourceCodePath}"
                    if (params.eNB_SourceCodePath == null) {
                        allParametersPresent = false
                    }
                    echo "params.eNB_Credentials = ${params.eNB_Credentials}"
                    if (params.eNB_Credentials == null) {
                        allParametersPresent = false
                    }
                    echo "params.UE_Credentials = ${params.UE_Credentials}"
                    if (params.UE_Credentials == null) {
                        allParametersPresent = false
                    }
                    GIT_COMMIT_AUTHOR = sh (
                        script: 'git show -s --pretty=%an',
                        returnStdout: true
                    ).trim()
                    echo "The author of the commit is: ${GIT_COMMIT_AUTHOR}"
                    GIT_COMMIT_EMAIL = sh (
                        script: 'git show -s --pretty=%ae',
                        returnStdout: true
                    ).trim()
                    echo "The email of the author is: ${GIT_COMMIT_EMAIL}"
                    echo "allParametersPresent = ${allParametersPresent}"
                    if (allParametersPresent) {
                        echo "All parameters are present"
                    } else {
                        echo "Some parameters are missing"
                        sh "./ci-scripts/fail.sh"
                    }
                    // The following parameters are kept not to break the current main.py command line and code.
                    // They should be removed in the future.
                    //if (params.ADB_IPAddress == null) {
                    //    params.ADB_IPAddress = "none"
                    //}
                    //echo "params.ADB_IPAddress = ${params.ADB_IPAddress}"
                }
            }
        }
Boris Djalal's avatar
Boris Djalal committed
197

Boris Djalal's avatar
Boris Djalal committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
        stage ("Build and Test") {
            steps {
        	    script {
        	        dir ('ci-scripts') {
        	    	echo "\u2705 \u001B[32m${testStageName}\u001B[0m"
        	    	echo "params.eNB_Credentials = ${params.eNB_Credentials}"
        	    	echo "params.UE_Credentials = ${params.UE_Credentials}"
        	    	echo "eNB_Repository = ${eNB_Repository}"
        	    	echo "eNB_Branch= ${eNB_Branch}"
        	    	echo "eNB_CommitID= ${eNB_CommitID}"
        	    	echo "eNB_AllowMergeRequestProcess= ${eNB_AllowMergeRequestProcess}"
        	    	echo "params.ADB_IPAddress= ${params.ADB_IPAddress}"
        	    	echo "ADB_IPAddress= ${ADB_IPAddress}"
        	    	echo "ADB_Username = ${ADB_Username}"
        	    	echo "ADB_Password = ${ADB_Password}"
        	    	echo "params.eNB_IPAddress = ${params.eNB_IPAddress}"
        	    	echo "params.eNB_SourceCodePath = ${params.eNB_SourceCodePath}"
        	    	echo "ADB_IPAddress = ${ADB_IPAddress}"
        	    	echo "EPC_IPAddress = ${EPC_IPAddress}"
Boris Djalal's avatar
Test  
Boris Djalal committed
217
        	    	echo "BUILD_STAGE_STATUS = ${BUILD_STAGE_STATUS}"
Boris Djalal's avatar
Boris Djalal committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231
        	    	withCredentials([
        	    	    [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'],
        	    	    [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.UE_Credentials}", usernameVariable: 'UE_Username', passwordVariable: 'UE_Password']
        	    	]) {
        	    	    sh "python3 main.py --mode=InitiateHtml --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNB_AllowMerge=${eNB_AllowMergeRequestProcess} --ADBIPAddress=${ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --eNBIPAddress=127.0.0.1 --eNBUserName=carabe --eNBPassword=${eNB_Password} ${mainPythonAllXmlFiles}"
        	    	    String[] myXmlTestSuite = testXMLFile.split("\\r?\\n")
        	    	    for (xmlFile in myXmlTestSuite) {
        	    	    if (fileExists(xmlFile)) {
        	    		try {
        	    		    echo "The test will be executed here. The command would be:"
        	    		    echo  "sh \"python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${params.eNB_Password} --eNBBranch=${eNB_Branch} --eNBSourceCodePath=${params.eNB_SourceCodePath} --eNBRepository=${eNB_Repository} --eNBCommitID=${eNB_CommitID} --ADBIPAddress=${ADB_IPAddress} --EPCIPAddress=${EPC_IPAddress} --XMLTestFile=${xmlFile}\""
        	    		    //sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${params.eNB_Password} --eNBBranch=${eNB_Branch} --eNBSourceCodePath=${params.eNB_SourceCodePath} --eNBRepository=${eNB_Repository} --eNBCommitID=${eNB_CommitID} --ADBIPAddress=${ADB_IPAddress} --EPCIPAddress=${EPC_IPAddress} --XMLTestFile=${xmlFile}"
        	    		} catch (Exception e) {
        	    		    currentBuild.result = 'FAILURE'
Boris Djalal's avatar
Test  
Boris Djalal committed
232
        	    		    BUILD_STAGE_STATUS = false
Boris Djalal's avatar
Boris Djalal committed
233 234 235
        	    		}
        	    	    }
        	    	    }
Boris Djalal's avatar
Test  
Boris Djalal committed
236
        	    	    sh "python3 main.py --mode=FinalizeHtml --finalStatus=${BUILD_STAGE_STATUS} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}"
Boris Djalal's avatar
Boris Djalal committed
237 238 239 240 241
        	    	}
        	        }
        	    }
            }
        }
Boris Djalal's avatar
Boris Djalal committed
242

Boris Djalal's avatar
Boris Djalal committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256
        stage ("Terminate") {
            parallel {
        	stage('Terminate NR UE') {
        	    steps {
        		echo '\u2705 \u001B[32mTerminate UE\u001B[0m'
        	    }
        	    post {
        		success {
        		    script {
        			termStatusArray[termUE] = true
        		    }
        		}
        	    }
        	}
Boris Djalal's avatar
Save.  
Boris Djalal committed
257 258 259 260 261 262 263 264
       	    stage('Terminate NR eNB') {
       	        steps {
		    echo '\u2705 \u001B[32mTerminate eNB\u001B[0m'
        	      }
                    post {
        	        success {
                            script {
        		        termStatusArray[termENB] = true
Boris Djalal's avatar
Boris Djalal committed
265
        		    }
Boris Djalal's avatar
Save.  
Boris Djalal committed
266
                        }
Boris Djalal's avatar
Boris Djalal committed
267
        	    }
Boris Djalal's avatar
Save.  
Boris Djalal committed
268
                }
Boris Djalal's avatar
Boris Djalal committed
269 270
            }
        }
Boris Djalal's avatar
Boris Djalal committed
271

Boris Djalal's avatar
Boris Djalal committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
        stage('Log Collection') {
            parallel {
        	stage('Log Collection (gNB and NR UE - Build)') {
        	    steps {
        		withCredentials([
        		     [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
        		]) {
        		    echo '\u2705 \u001B[32mLog Collection (gNB and NR UE - Build)\u001B[0m'
        		    sh "python3 ci-scripts/main.py --mode=LogCollectBuild --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}"
        
        		    echo '\u2705 \u001B[32mLog Transfer (gNB and NR UE - Build)\u001B[0m'
        		    sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/build.log.zip ./build.log.${env.BUILD_ID}.zip || true"
        		}
        		script {
        		    if(fileExists("build.log.${env.BUILD_ID}.zip")) {
        			archiveArtifacts "build.log.${env.BUILD_ID}.zip"
        		    }
        		}
        	    }
        	}
        	stage('Log Collection (gNB - Run)') {
        	    steps {
        		withCredentials([
        		     [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
        		]) {
        		    echo '\u2705 \u001B[32mLog Collection (gNB - Run)\u001B[0m'
        		    sh "python3 ci-scripts/main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}"
        
        		    echo '\u2705 \u001B[32mLog Transfer (gNB - Run)\u001B[0m'
        		    sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/gnb.log.zip ./gnb.log.${env.BUILD_ID}.zip || true"
        		}
        		script {
        		    if(fileExists("gnb.log.${env.BUILD_ID}.zip")) {
        			archiveArtifacts "gnb.log.${env.BUILD_ID}.zip"
        		    }
        		    if(fileExists("ci-scripts/test_results.html")) {
        			sh "mv ci-scripts/test_results.html test_results-${JOB_NAME}.html"
        			sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: <a href=\"${BUILD_URL}\">${BUILD_ID}</a>#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html"
        			archiveArtifacts "test_results-${JOB_NAME}.html"
        		    }
        		}
        	    }
        	}
        	stage('Log Collection (NR UE - Run)') {
        	    steps {
        		withCredentials([
        		     [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
        		]) {
        		    echo '\u2705 \u001B[32mLog Collection (gNB - Run)\u001B[0m'
        		    sh "python3 ci-scripts/main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}"
        
        		    echo '\u2705 \u001B[32mLog Transfer (gNB - Run)\u001B[0m'
        		    sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/nr-ue.log.zip ./nr-ue.log.${env.BUILD_ID}.zip || true"
        		}
        		script {
        		    if(fileExists("nr-ue.log.${env.BUILD_ID}.zip")) {
        			archiveArtifacts "nr-ue.log.${env.BUILD_ID}.zip"
        		    }
        		    if(fileExists("ci-scripts/test_results.html")) {
        			sh "mv ci-scripts/test_results.html test_results-${JOB_NAME}.html"
        			sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: <a href=\"${BUILD_URL}\">${BUILD_ID}</a>#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html"
        			archiveArtifacts "test_results-${JOB_NAME}.html"
        		    }
        		}
        	    }
        	}
            }
        }
Boris Djalal's avatar
Boris Djalal committed
340
    }
Boris Djalal's avatar
Boris Djalal committed
341 342

    post {
Boris Djalal's avatar
Boris Djalal committed
343 344 345 346
        always {
            script {
                // Stage destroy may not be run if error in previous stage
                //sh "./ci-scripts/oai-ci-vm-tool destroy --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
Boris Djalal's avatar
Save  
Boris Djalal committed
347
		echo "PROJECT_NAME = ${PROJECT_NAME}"		
Boris Djalal's avatar
Boris Djalal committed
348
		echo "BUILD_NUMBER = ${BUILD_NUMBER}"		
Boris Djalal's avatar
Boris Djalal committed
349 350 351 352 353
		echo "BUILD_STAGE_STATUS = ${BUILD_STAGE_STATUS}"
		echo "GIT_URL = ${GIT_URL}"
		echo "env.gitlabSourceBranch = ${env.gitlabSourceBranch}"
		echo "env.gitlabMergeRequestLastCommit = ${env.gitlabMergeRequestLastCommit}"
		echo "env.gitlabTargetBranch = ${env.gitlabTargetBranch}"		
Boris Djalal's avatar
Boris Djalal committed
354 355
                emailext attachmentsPattern: '*results*.html',
                     body: '''Hi,
Boris Djalal's avatar
Test  
Boris Djalal committed
356
Here are attached HTML report files for $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STAGE_STATUS
Boris Djalal's avatar
Boris Djalal committed
357 358 359 360

Regards,
OAI CI Team''',
                     replyTo: 'no-reply@openairinterface.org',
Boris Djalal's avatar
Test  
Boris Djalal committed
361
                     subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STAGE_STATUS',
Boris Djalal's avatar
Boris Djalal committed
362
                     to: GIT_COMMIT_EMAIL
Boris Djalal's avatar
Boris Djalal committed
363 364 365 366 367 368 369 370 371
		     gitlabCommitStatus(name: "boris-test") {
		     build job: 'boris-test',
		         parameters: [
			     string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
			     string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)),
			     string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)),
			     booleanParam(name: 'eNB_mergeRequest', value: true),
			     string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
		       ]
Boris Djalal's avatar
Boris Djalal committed
372
		    }
Boris Djalal's avatar
Boris Djalal committed
373
		}
Boris Djalal's avatar
Boris Djalal committed
374 375 376 377 378 379 380 381
            }
        success {
            script {
                def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ")"
                if ("MERGE".equals(env.gitlabActionType)) {
                    echo "This is a MERGE event"
                    addGitLabMRComment comment: message
                    def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
Boris Djalal's avatar
Boris Djalal committed
382
                    sendSocialMediaMessage('develop-nr', 'good', message2)
Boris Djalal's avatar
Boris Djalal committed
383
                } else {
Boris Djalal's avatar
Boris Djalal committed
384
                    sendSocialMediaMessage('develop-nr', 'good', message)
Boris Djalal's avatar
Boris Djalal committed
385 386 387 388 389 390 391 392 393 394
                }
            }
        }
        failure {
            script {
                def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ")"
                if ("MERGE".equals(env.gitlabActionType)) {
                    echo "This is a MERGE event"
                    addGitLabMRComment comment: message
                    def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
Boris Djalal's avatar
Boris Djalal committed
395
                    sendSocialMediaMessage('develop-nr', 'danger', message2)
Boris Djalal's avatar
Boris Djalal committed
396
                } else {
Boris Djalal's avatar
Boris Djalal committed
397
                    sendSocialMediaMessage('develop-nr', 'danger', message)
Boris Djalal's avatar
Boris Djalal committed
398 399 400
                }
            }
        }
Boris Djalal's avatar
Boris Djalal committed
401
    }
402
}
Boris Djalal's avatar
Boris Djalal committed
403