Jenkinsfile-tmp-ran 27.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/groovy
/*
 * 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
 */

// Template Jenkins Declarative Pipeline script to run Test w/ RF HW

// Location of the python executor node shall be in the same subnet as the others servers
def pythonExecutor = params.pythonExecutor

// Location of the test XML file to be run
def testXMLFile = params.pythonTestXmlFile

// Name of the test stage
def testStageName = params.pipelineTestStageName

// Terminate Status
def termUE = 0
def termENB = 1
def termSPGW = 2
def termMME = 3
def termHSS = 4
def termStatusArray = new Boolean[termHSS + 1]
termStatusArray[termUE] = false
termStatusArray[termENB] = false
termStatusArray[termSPGW] = false
termStatusArray[termMME] = false
termStatusArray[termHSS] = false

Raphael Defosseux's avatar
Raphael Defosseux committed
47 48
// Global Parameters. Normally they should be populated when the master job
// triggers the slave job with parameters
49 50 51
def eNB_Repository
def eNB_Branch
def eNB_CommitID
Raphael Defosseux's avatar
Raphael Defosseux committed
52
def eNB_AllowMergeRequestProcess = false
53 54 55

pipeline {
    agent {
56
        label pythonExecutor
57 58 59 60
    }
    options {
        disableConcurrentBuilds()
        timestamps()
61
        ansiColor('xterm')
62 63 64 65 66 67
    }
    // the following parameter options are commented out so it shows the ones
    // that you SHALL have to run the job.
    // You can use them as template
    /*
    parameters {
68 69 70 71 72 73
        //node-test parameters
        string(name: 'pythonExecutor', defaultValue: 'nodea', description: 'Node where the pipeline - python scripts will be executed')
        string(name: 'pythonTestXmlFile', defaultValue: 'enb_usrpB210_band7_50PRB.xml', description: 'Location of the Test XML to be run')
        string(name: 'pipelineTestStageName', defaultValue: 'Test COTS-UE - OAI eNB - LTEBOX EPC', description: 'Naming of the Test Stage')
        booleanParam(name: 'pipelineZipsConsoleLog', defaultValue: 'True', description: 'If true, the pipeline script retrieves the job console log, zips it and archives it as artifact')

74 75 76
        //eNB parameters
        string(name: 'eNB_IPAddress', defaultValue: '192.168.XX.XX', description: 'IP Address of eNB')
        credentials(name: 'eNB_Credentials', defaultValue: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', credentialType: "Username with password", required: true, description: 'Credentials for eNB')
77
        string(name: 'eNB_SourceCodePath', defaultValue: '/tmp/CI-enb', description: 'Full path of eNB source code')
78 79 80

        //EPC parameters
        string(name: 'EPC_IPAddress', defaultValue: '192.168.XX.XX', description: 'IP Address of EPC')
81
        string(name: 'EPC_Type', defaultValue: 'ltebox', description: 'EPC type: OAI or ltebox')
82
        credentials(name: 'EPC_Credentials', defaultValue: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', credentialType: "Username with password", required: true, description: 'Credentials for EPC')
83
        string(name: 'EPC_SourceCodePath', defaultValue: '/tmp/CI-enb', description: 'Full path of EPC source code')
84 85 86 87 88 89 90 91 92 93 94

        //ADB server parameters
        string(name: 'ADB_IPAddress', defaultValue: '192.168.XX.XX', description: 'IP Address of ADB server')
        credentials(name: 'ADB_Credentials', defaultValue: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', credentialType: "Username with password", required: true, description: 'Credentials for ADB')
    }
    */

    stages {
        stage ("Verify Parameters") {
            steps {
                script {
95
                    echo '\u2705 \u001B[32mVerify Parameters\u001B[0m'
96
                    def allParametersPresent = true
97 98 99 100 101 102 103 104 105

                    // It is already to late to check it
                    if (params.pythonExecutor != null) {
                        echo "eNB CI executor node  :   ${pythonExecutor}"
                    }
                    // If not present picking a default XML file
                    if (params.pythonTestXmlFile == null) {
                        // picking default
                        testXMLFile = 'xml_files/enb_usrpB210_band7_50PRB.xml'
106
                    } else {
107 108 109 110 111 112
                        echo "Test XML file         :   ${testXMLFile}"
                    }
                    // If not present picking a default Stage Name
                    if (params.pipelineTestStageName == null) {
                        // picking default
                        testStageName = 'Template Test Stage'
113 114 115 116 117 118 119 120 121 122 123
                    }

                    if (params.eNB_IPAddress == null) {
                        allParametersPresent = false
                    }
                    if (params.eNB_SourceCodePath == null) {
                        allParametersPresent = false
                    }
                    if (params.eNB_Credentials == null) {
                        allParametersPresent = false
                    }
Raphael Defosseux's avatar
Raphael Defosseux committed
124
                    // the following 4 parameters should be pushed by the master trigger
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
                    // if not present, take the job GIT variables (used for developing)
                    if (params.eNB_Repository == null) {
                        eNB_Repository = env.GIT_URL
                    } else {
                        eNB_Repository = params.eNB_Repository
                    }
                    echo "eNB_Repository        :   ${eNB_Repository}"
                    if (params.eNB_Branch == null) {
                        eNB_Branch = env.GIT_BRANCH
                    } else {
                        eNB_Branch = params.eNB_Branch
                    }
                    echo "eNB_Branch            :   ${eNB_Branch}"
                    if (params.eNB_CommitID == null) {
                        eNB_CommitID = env.GIT_COMMIT
                    } else {
                        eNB_CommitID = params.eNB_CommitID
                    }
                    echo "eNB_CommitID          :   ${eNB_CommitID}"
Raphael Defosseux's avatar
Raphael Defosseux committed
144 145 146
                    if (params.eNB_mergeRequest != null) {
                        eNB_AllowMergeRequestProcess = params.eNB_mergeRequest
                    }
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

                    if (params.EPC_IPAddress == null) {
                        allParametersPresent = false
                    }
                    if (params.EPC_Type == null) {
                        allParametersPresent = false
                    }
                    if (params.EPC_SourceCodePath == null) {
                        allParametersPresent = false
                    }
                    if (params.EPC_Credentials == null) {
                        allParametersPresent = false
                    }

                    if (params.ADB_IPAddress == null) {
                        allParametersPresent = false
                    }
                    if (params.ADB_Credentials == null) {
                        allParametersPresent = false
                    }

                    if (allParametersPresent) {
                        echo "All parameters are present"
                    } else {
                        echo "Some parameters are missing"
                        sh "./ci-scripts/fail.sh"
                    }
                }
            }
        }
177
        stage ("Build and Test") {
178 179 180 181
            steps {
                script {
                    dir ('ci-scripts') {
                        try {
182
                            echo "\u2705 \u001B[32m${testStageName}\u001B[0m"
183 184 185 186 187
                            withCredentials([
                                [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'],
                                [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'],
                                [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password']
                            ]) {
Raphael Defosseux's avatar
Raphael Defosseux committed
188
                                sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNB_AllowMerge=${eNB_AllowMergeRequestProcess} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${testXMLFile}"
189 190 191 192 193 194 195 196
                            }
                        } catch (Exception e) {
                            currentBuild.result = 'FAILURE'
                        }
                    }
                }
            }
        }
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
        stage ("Terminate") {
            parallel {
                stage('Terminate UE') {
                    steps {
                        echo '\u2705 \u001B[32mTerminate UE\u001B[0m'
                        withCredentials([
                            [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password']
                        ]) {
                            sh "python3 ci-scripts/main.py --mode=TerminateUE --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password}"
                        }
                    }
                    post {
                        success {
                            script {
                                termStatusArray[termUE] = true
212 213 214 215
                            }
                        }
                    }
                }
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
                stage('Terminate eNB') {
                    steps {
                        echo '\u2705 \u001B[32mTerminate eNB\u001B[0m'
                        withCredentials([
                            [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
                        ]) {
                            sh "python3 ci-scripts/main.py --mode=TerminateeNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}"
                        }
                    }
                    post {
                        success {
                            script {
                                termStatusArray[termENB] = true
                            }
                        }
                    }
                }
                stage('Terminate SPGW') {
                    steps {
                        echo '\u2705 \u001B[32mTerminate SPGW\u001B[0m'
                        withCredentials([
                            [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            sh "python3 ci-scripts/main.py --mode=TerminateSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
                        }
                    }
                    post {
                        success {
                            script {
                                termStatusArray[termSPGW] = true
                            }
                        }
                    }
                }
                stage('Terminate MME') {
                    steps {
                        echo '\u2705 \u001B[32mTerminate MME\u001B[0m'
                        withCredentials([
                            [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            sh "python3 ci-scripts/main.py --mode=TerminateMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
                        }
                    }
                    post {
                        success {
                            script {
                                termStatusArray[termMME] = true
                            }
                        }
                    }
                }
                stage('Terminate HSS') {
                    steps {
                        echo '\u2705 \u001B[32mTerminate HSS\u001B[0m'
                        withCredentials([
                            [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            sh "python3 ci-scripts/main.py --mode=TerminateHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
                        }
                    }
                    post {
                        success {
                            script {
                                termStatusArray[termHSS] = true
280 281 282 283 284 285 286 287
                            }
                        }
                    }
                }
            }
        }
        stage('Log Collection') {
            parallel {
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
                stage('Log Collection (eNB - Build)') {
                    steps {
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (eNB - 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 (eNB - 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 (eNB - Run)') {
                    steps {
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (eNB - 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 (eNB - Run)\u001B[0m'
                            sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/enb.log.zip ./enb.log.${env.BUILD_ID}.zip || true"
                        }
                        script {
                            if(fileExists("enb.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "enb.log.${env.BUILD_ID}.zip"
                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
321 322
                            if(fileExists("ci-scripts/test_results.html")) {
                                sh "mv ci-scripts/test_results.html test_results-${JOB_NAME}.html"
Raphael Defosseux's avatar
Raphael Defosseux committed
323
                                sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's#TEMPLATE_BUILD_ID#<a href=\"${BUILD_URL}\">${BUILD_ID}</a>#' test_results-${JOB_NAME}.html"
Raphael Defosseux's avatar
Raphael Defosseux committed
324 325
                                archiveArtifacts "test_results-${JOB_NAME}.html"
                            }
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
                        }
                    }
                }
                stage('Log Collection (SPGW)') {
                    steps {
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (SPGW)\u001B[0m'
                            sh "python3 ci-scripts/main.py --mode=LogCollectSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}"

                            echo '\u2705 \u001B[32mLog Transfer (SPGW)\u001B[0m'
                            sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/spgw.log.zip ./spgw.log.${env.BUILD_ID}.zip || true"
                        }
                        script {
                            if(fileExists("spgw.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "spgw.log.${env.BUILD_ID}.zip"
                            }
                        }
                    }
                }
                stage('Log Collection (MME)') {
348
                    steps {
349 350 351 352 353 354 355 356 357
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (MME)\u001B[0m'
                            sh "python3 ci-scripts/main.py --mode=LogCollectMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}"

                            echo '\u2705 \u001B[32mLog Transfer (MME)\u001B[0m'
                            sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/mme.log.zip ./mme.log.${env.BUILD_ID}.zip || true"
                        }
358
                        script {
359 360
                            if(fileExists("mme.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "mme.log.${env.BUILD_ID}.zip"
361 362 363 364
                            }
                        }
                    }
                }
365
                stage('Log Collection (HSS)') {
366
                    steps {
367 368 369 370 371 372 373 374 375
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (HSS)\u001B[0m'
                            sh "python3 ci-scripts/main.py --mode=LogCollectHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}"

                            echo '\u2705 \u001B[32mLog Transfer (HSS)\u001B[0m'
                            sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/hss.log.zip ./hss.log.${env.BUILD_ID}.zip || true"
                        }
376
                        script {
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
                            if(fileExists("hss.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "hss.log.${env.BUILD_ID}.zip"
                            }
                        }
                    }
                }
                stage('Log Collection (Ping)') {
                    steps {
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (Ping)\u001B[0m'
                            sh "python3 ci-scripts/main.py --mode=LogCollectPing --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}"

                            echo '\u2705 \u001B[32mLog Transfer (Ping)\u001B[0m'
                            sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/ping.log.zip ./ping.log.${env.BUILD_ID}.zip || true"
                        }
                        script {
                            if(fileExists("ping.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "ping.log.${env.BUILD_ID}.zip"
397 398 399 400
                            }
                        }
                    }
                }
Raphael Defosseux's avatar
Raphael Defosseux committed
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
                stage('Log Collection (Iperf)') {
                    steps {
                        withCredentials([
                             [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                        ]) {
                            echo '\u2705 \u001B[32mLog Collection (Iperf)\u001B[0m'
                            sh "python3 ci-scripts/main.py --mode=LogCollectIperf --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}"

                            echo '\u2705 \u001B[32mLog Transfer (Iperf)\u001B[0m'
                            sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/iperf.log.zip ./iperf.log.${env.BUILD_ID}.zip || true"
                        }
                        script {
                            if(fileExists("iperf.log.${env.BUILD_ID}.zip")) {
                                archiveArtifacts "iperf.log.${env.BUILD_ID}.zip"
                            }
                        }
                    }
                }
419 420 421 422 423 424 425
            }
        }
    }

    post {
        always {
            script {
426 427 428 429 430 431 432 433 434
                if (params.pipelineZipsConsoleLog != null) {
                    if (params.pipelineZipsConsoleLog) {
                        echo "Archiving Jenkins console log"
                        sh "wget --no-check-certificate --no-proxy ${env.JENKINS_URL}/job/${env.JOB_NAME}/${env.BUILD_ID}/consoleText -O consoleText.log || true"
                        sh "zip -m consoleText.log.${env.BUILD_ID}.zip consoleText.log || true"
                        if(fileExists("consoleText.log.${env.BUILD_ID}.zip")) {
                            archiveArtifacts "consoleText.log.${env.BUILD_ID}.zip"
                        }
                    }
435 436 437
                }
            }
        }
438
        // Making sure that we really shutdown every thing before leaving
439 440
        failure {
            script {
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
                if (!termStatusArray[termUE]) {
                    withCredentials([
                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password']
                    ]) {
                        sh "python3 ci-scripts/main.py --mode=TerminateUE --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password}"
                    }
                }
                if (!termStatusArray[termENB]) {
                    withCredentials([
                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
                    ]) {
                        sh "python3 ci-scripts/main.py --mode=TerminateeNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}"
                    }
                }
                if (!termStatusArray[termSPGW]) {
                    withCredentials([
                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                    ]) {
                        sh "python3 ci-scripts/main.py --mode=TerminateSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
                    }
                }
                if (!termStatusArray[termMME]) {
                    withCredentials([
                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                    ]) {
                        sh "python3 ci-scripts/main.py --mode=TerminateMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
                    }
                }
                if (!termStatusArray[termHSS]) {
                    withCredentials([
                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                    ]) {
                        sh "python3 ci-scripts/main.py --mode=TerminateHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}"
474 475 476 477
                    }
                }
            }
        }
478 479
    }
}