Jenkinsfile-gitlab 44.4 KB
Newer Older
1
#!/bin/groovy
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */
22

23 24 25 26 27 28 29 30 31 32
// Abstraction function to send social media messages:
// like on Slack or Mattermost
def sendSocialMediaMessage(pipeChannel, pipeColor, pipeMessage) {
    if (params.pipelineUsesSlack != null) {
        if (params.pipelineUsesSlack) {
            slackSend channel: pipeChannel, color: pipeColor, message: pipeMessage
        }
    }
}

Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
33
def doRedHatBuild = false
34
def doFlexranCtrlTest = false
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
35

36 37 38
// Location of the executor node
def nodeExecutor = params.nodeExecutor

39 40
pipeline {
    agent {
41
        label nodeExecutor
42 43 44 45 46
    }
    options {
        disableConcurrentBuilds()
        timestamps()
        gitLabConnection('OAI GitLab')
47
        gitlabBuilds(builds: ["Build eNb-USRP", "Build basic-sim", "Build phy-sim", "Build eNb-ethernet", "Build UE-ethernet", "Analysis with cppcheck", "Test phy-sim", "Test basic-sim", "Test L2-sim", "Test-Mono-FDD-Band7", "Test-Mono-TDD-Band40", "Test-IF4p5-FDD-Band7", "Test-IF4p5-TDD-Band40", "Test-Mono-FDD-Band13"])
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
48
        ansiColor('xterm')
49 50 51
    }

    stages {
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
52 53 54
        stage ("Verify Parameters") {
            steps {
                script {
55 56 57
                    JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"'
                    JOB_TIMESTAMP = JOB_TIMESTAMP.trim()

Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
58 59 60 61 62 63 64 65 66 67 68 69 70
                    echo '\u2705 \u001B[32mVerify Parameters\u001B[0m'
                    def allParametersPresent = true

                    if (params.RedHatRemoteServer == null) {
                        allParametersPresent = false
                    }
                    if (params.RedHatRemoteCredentials == null) {
                        allParametersPresent = false
                    }
                    if (params.RedHatWorkingPath == null) {
                        allParametersPresent = false
                    }
                    if (allParametersPresent) {
71
                        echo "Performing Red Hat Build"
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
72 73 74 75
                        doRedHatBuild = true
                    } else {
                        doRedHatBuild = false
                    }
76
                    if (params.FlexRanRtcGitLabRepository_Credentials != null) {
Raphael Defosseux's avatar
Raphael Defosseux committed
77
                        doFlexranCtrlTest = true
78 79 80 81
                    }
                    if (fileExists("flexran")) {
                        sh "rm -Rf flexran > /dev/null 2>&1"
                    }
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
82 83 84
                }
            }
        }
85
        stage ("Verify Guidelines") {
86 87 88 89 90
            steps {
                echo "Git URL         is ${GIT_URL}"
                echo "GitLab Act      is ${env.gitlabActionType}"
                script {
                    if ("MERGE".equals(env.gitlabActionType)) {
Raphael Defosseux's avatar
Raphael Defosseux committed
91 92 93
                        // since a bit, in push events, gitlabUserEmail is not populated
                        gitCommitAuthorEmailAddr = ${env.gitlabUserEmail}
                        echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
94
                        // GitLab-Jenkins plugin integration is lacking to perform the merge by itself
95
                        // Doing it manually --> it may have merge conflicts
96
                        sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
97
                        sh "zip -r -qq localZip.zip ."
98 99 100 101

                        // Running astyle options on the list of modified files by the merge request
                        // For the moment, there is no fail criteria. Just a notification of number of files that do not follow
                        sh "./ci-scripts/checkCodingFormattingRules.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}"
102 103
                        def res=readFile('./oai_rules_result.txt').trim();
                        if ("0".equals(res)) {
104 105
                            def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): All Changed files in Merge Request follow OAI Formatting Rules"
                            addGitLabMRComment comment: message
106
                        } else {
107 108
                            def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some Changed files in Merge Request DO NOT follow OAI Formatting Rules"
                            addGitLabMRComment comment: message
109 110 111 112
                        }
                    } else {
                        echo "Git Branch      is ${GIT_BRANCH}"
                        echo "Git Commit      is ${GIT_COMMIT}"
Raphael Defosseux's avatar
Raphael Defosseux committed
113 114 115 116
                        // since a bit, in push events, gitlabUserEmail is not populated
                        gitCommitAuthorEmailAddr = sh returnStdout: true, script: 'git log -n1 --pretty=format:%ae ${GIT_COMMIT}'
                        gitCommitAuthorEmailAddr = gitCommitAuthorEmailAddr.trim()
                        echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
117
                        sh "git log -n1 --pretty=format:\"%s\" > .git/CI_COMMIT_MSG"
118

119
                        sh "zip -r -qq localZip.zip ."
120 121
                        // Running astyle options on all C/H files in the repository
                        // For the moment, there is no fail criteria. Just a notification of number of files that do not follow
122
                        sh "./ci-scripts/checkCodingFormattingRules.sh"
123
                    }
124 125 126 127 128 129 130 131 132 133 134 135
                    if (doFlexranCtrlTest) {
                        sh "mkdir flexran"
                        dir ('flexran') {
                            withCredentials([
                                [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.FlexRanRtcGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_password']
                                ]) {
                                sh "git clone https://${git_username}:${git_password}@gitlab.eurecom.fr/flexran/flexran-rtc.git . > ../git_clone.log 2>&1"
                            }
                            sh "sed -i -e 's#add-apt-repository.*cleishm.*neo4j#add-apt-repository ppa:cleishm/neo4j -y#' -e 's#libneo4j-client-dev#libneo4j-client-dev -y#' tools/install_dependencies"
                            sh "zip -r -qq flexran.zip ."
                        }
                    }
136 137
                }
            }
138 139
            post {
                failure {
140 141 142
                    script {
                        def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Merge Conflicts -- Cannot perform CI"
                        addGitLabMRComment comment: message
Boris Djalal's avatar
Boris Djalal committed
143
                        currentBuild.result = 'FAILURE'
144
                    }
145 146
                }
            }
147
        }
148

149
        stage ("Start VM -- basic-sim") {
150
            steps {
151
                timeout (time: 5, unit: 'MINUTES') {
152
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
153
                }
154 155 156 157 158
            }
        }

        stage ("Start VM -- enb-usrp") {
            steps {
159
                timeout (time: 5, unit: 'MINUTES') {
160
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant enb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
161
                }
162 163 164
            }
        }

165
        stage ("Start VM -- enb-ethernet") {
166
            steps {
167
                timeout (time: 5, unit: 'MINUTES') {
168
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant enb-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
169
                }
170 171 172
            }
        }

173
        stage ("Start VM -- ue-ethernet") {
174
            steps {
175
                timeout (time: 5, unit: 'MINUTES') {
176
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant ue-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
177
                }
178 179 180
            }
        }

181 182 183 184 185 186 187 188
        stage ("Start VM -- L2-Sim") {
            steps {
                timeout (time: 5, unit: 'MINUTES') {
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant l2-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
                }
            }
        }

189
        stage ("Start VM -- phy-sim") {
190
            steps {
191
                timeout (time: 5, unit: 'MINUTES') {
192
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
193
                }
194 195 196
            }
        }

197
        stage ("Start VM -- cppcheck") {
198
            steps {
199
                timeout (time: 5, unit: 'MINUTES') {
200
                    sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon"
201
                }
202 203 204
            }
        }

205 206
        stage ("Variant Builds") {
            parallel {
207 208 209
                stage ("Analysis with cppcheck") {
                    steps {
                        gitlabCommitStatus(name: "Analysis with cppcheck") {
210
                            timeout (time: 20, unit: 'MINUTES') {
211
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant cppcheck --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
212
                            }
213 214 215
                        }
                    }
                }
216 217 218
                stage ("Build eNb-USRP") {
                    steps {
                        gitlabCommitStatus(name: "Build eNb-USRP") {
219
                            timeout (time: 20, unit: 'MINUTES') {
220
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant enb-usrp --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
221
                            }
222 223 224 225 226 227
                        }
                    }
                }
                stage ("Build basic simulator") {
                    steps {
                        gitlabCommitStatus(name: "Build basic-sim") {
228
                            timeout (time: 20, unit: 'MINUTES') {
229
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
230
                            }
231 232
                        }
                    }
233
                }
234
                stage ("Build eNb-ethernet") {
Raphael Defosseux's avatar
Raphael Defosseux committed
235
                    steps {
236
                        gitlabCommitStatus(name: "Build eNb-ethernet") {
237
                            timeout (time: 20, unit: 'MINUTES') {
238
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant enb-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
239
                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
240 241 242
                        }
                    }
                }
243
                stage ("Build UE-ethernet") {
244
                    steps {
245
                        gitlabCommitStatus(name: "Build UE-ethernet") {
246
                            timeout (time: 20, unit: 'MINUTES') {
247
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant ue-ethernet --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
248
                            }
249 250 251
                        }
                    }
                }
252 253 254 255 256 257 258 259 260
                stage ("Build L2-Simulator-eNB") {
                    steps {
                        //gitlabCommitStatus(name: "Build UE-ethernet") {
                            timeout (time: 20, unit: 'MINUTES') {
                                sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant l2-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
                            }
                        //}
                    }
                }
261
                stage ("Build physical simulators") {
262
                    steps {
263
                        gitlabCommitStatus(name: "Build phy-sim") {
264
                            timeout (time: 20, unit: 'MINUTES') {
265
                               sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
266
                            }
267 268 269
                        }
                    }
                }
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
270 271 272 273 274
                stage ("Build eNb-USRP on Red Hat") {
                    when {
                        expression {doRedHatBuild}
                    }
                    steps {
275
                        gitlabCommitStatus(name: "Build eNb-USRP-RHE") {
Raphael Defosseux's avatar
Raphael Defosseux committed
276 277 278 279 280
                            script {
                                try {
                                    withCredentials([
                                        [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.RedHatRemoteCredentials}", usernameVariable: 'RH_Username', passwordVariable: 'RH_Password']
                                    ]) {
281 282 283
                                        timeout (time: 20, unit: 'MINUTES') {
                                            sh "./ci-scripts/buildOnRH.sh --workspace $WORKSPACE --job-name ${JOB_NAME} --build-id ${BUILD_ID} --remote-host ${params.RedHatRemoteServer} --remote-path ${params.RedHatWorkingPath} --remote-user-name ${RH_Username} --remote-password ${RH_Password}"
                                        }
Raphael Defosseux's avatar
Raphael Defosseux committed
284 285
                                    }
                                } catch (Exception e) {
286
                                    echo "Red Hat build failed but we could keep running pipeline if all ubuntu-based build passed"
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
287 288 289 290 291
                                }
                            }
                        }
                    }
                }
292 293
            }
            post {
Boris Djalal's avatar
Boris Djalal committed
294 295 296 297 298
                failure {
                    script {
                        currentBuild.result = 'FAILURE'
                    }
                }
299 300
                always {
                    script {
301
                        dir ('archives') {
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
302
                            sh "zip -r -qq vm_build_logs.zip basic_sim enb_usrp phy_sim cppcheck enb_eth ue_eth red_hat"
303 304 305
                        }
                        if(fileExists('archives/vm_build_logs.zip')) {
                            archiveArtifacts artifacts: 'archives/vm_build_logs.zip'
306 307
                        }
                        if ("MERGE".equals(env.gitlabActionType)) {
308
                            sh "./ci-scripts/oai-ci-vm-tool report-build --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
309 310 311 312 313 314 315 316 317 318 319
                            // If the merge request has introduced more CPPCHECK errors or warnings, notifications in GitLab
                            if (fileExists('oai_cppcheck_added_errors.txt')) {
                                def ret=readFile('./oai_cppcheck_added_errors.txt').trim();
                                if ("0".equals(ret)) {
                                    echo "No added cppcheck warnings/errors in this merge request"
                                } else {
                                    def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some modified files in Merge Request MAY have INTRODUCED up to " + ret + " CPPCHECK errors/warnings"
                                    addGitLabMRComment comment: message
                                }
                            }
                            // If the merge request has introduced compilation warnings, notifications in GitLab
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
320 321 322 323 324
                            sh "./ci-scripts/checkAddedWarnings.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}"
                            def res=readFile('./oai_warning_files.txt').trim();
                            if ("0".equals(res)) {
                                echo "No issues w/ warnings/errors in this merge request"
                            } else {
325
                                def fileList=readFile('./oai_warning_files_list.txt').trim();
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
326 327 328
                                def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some modified files in Merge Request MAY have INTRODUCED WARNINGS (" + fileList + ")"
                                addGitLabMRComment comment: message
                            }
329
                        } else {
330
                            sh "./ci-scripts/oai-ci-vm-tool report-build --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger push --branch ${GIT_BRANCH} --commit ${GIT_COMMIT}"
331 332
                        }
                        if(fileExists('build_results.html')) {
333
                            sh "sed -i -e 's#Build-ID: ${BUILD_ID}#Build-ID: <a href=\"${BUILD_URL}\">${BUILD_ID}</a>#' -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' build_results.html"
334 335 336 337 338 339
                            archiveArtifacts artifacts: 'build_results.html'
                        }
                    }
                }
            }
        }
Raphael Defosseux's avatar
Raphael Defosseux committed
340

Raphael Defosseux's avatar
Raphael Defosseux committed
341 342
        stage ("Variant Tests") {
            parallel {
343 344 345 346
                stage ("VM-based tests") {
                    stages {
                        stage ("Test physical simulators") {
                            steps {
347
                                script {
Raphael Defosseux's avatar
Raphael Defosseux committed
348 349 350
                                    timeout (time: 20, unit: 'MINUTES') {
                                        try {
                                            gitlabCommitStatus(name: "Test phy-sim") {
351 352
                                                sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
                                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
353 354
                                        } catch (Exception e) {
                                          currentBuild.result = 'FAILURE'
355
                                        }
356 357
                                    }
                                }
358
                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
359
                        }
360 361 362 363 364
                        stage ("Build Flexran Controller") {
                            when {
                                expression {doFlexranCtrlTest}
                            }
                            steps {
365 366 367 368 369 370 371 372
                                script {
                                    timeout (time: 20, unit: 'MINUTES') {
                                        try {
                                            sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant flexran-rtc --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive"
                                        } catch (Exception e) {
                                          currentBuild.result = 'FAILURE'
                                        }
                                    }
373
                                }
374
                            }
375
                        }
376 377
                        stage ("Test basic simulator") {
                            steps {
378
                                script {
Raphael Defosseux's avatar
Raphael Defosseux committed
379 380 381
                                    timeout (time: 30, unit: 'MINUTES') {
                                        try {
                                            gitlabCommitStatus(name: "Test basic-sim") {
382 383
                                                sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant basic-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
                                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
384 385
                                        } catch (Exception e) {
                                          currentBuild.result = 'FAILURE'
386
                                        }
387 388
                                    }
                                }
389
                            }
390
                        }
391 392
                        stage ("Test L2 simulator") {
                            steps {
393
                                script {
Raphael Defosseux's avatar
Raphael Defosseux committed
394 395 396
                                    timeout (time: 30, unit: 'MINUTES') {
                                        try {
                                            gitlabCommitStatus(name: "Test L2-sim") {
397 398
                                                sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant l2-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
                                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
399 400
                                        } catch (Exception e) {
                                            currentBuild.result = 'FAILURE'
401
                                        }
402 403 404
                                    }
                                }
                            }
405 406 407
                        }
                    }
                }
408
                stage ("Test MONOLITHIC - FDD - Band 7 - B210") {
409 410 411
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
412
                                gitlabCommitStatus(name: "Test-Mono-FDD-Band7") {
413 414 415 416 417
                                    build job: 'eNB-CI-FDD-Band7-B210',
                                       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)),
418 419
                                           booleanParam(name: 'eNB_mergeRequest', value: true),
                                           string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
420 421 422
                                       ]
                                }
                            } else {
423
                                gitlabCommitStatus(name: "Test-Mono-FDD-Band7") {
424 425 426 427 428 429 430
                                    build job: 'eNB-CI-FDD-Band7-B210',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
Raphael Defosseux's avatar
Raphael Defosseux committed
431
                                }
432
                            }
433 434 435 436
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
437
                        // slave job. The only drop-back is that we may retrieve the HTML report of a previous build
438 439 440 441 442 443 444 445 446
                        always {
                            script {
                                if (!fileExists('test_results-eNB-CI-FDD-Band7-B210.html')) {
                                    copyArtifacts(projectName: 'eNB-CI-FDD-Band7-B210',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-eNB-CI-FDD-Band7-B210.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-eNB-CI-FDD-Band7-B210.html"
                                        archiveArtifacts artifacts: 'test_results-eNB-CI-FDD-Band7-B210.html'
447
                                    }
448 449 450
                                }
                            }
                        }
451 452 453 454 455
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
456 457
                    }
                }
458
                stage ("Test MONOLITHIC - TDD - Band 40 - B210") {
459 460 461
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
462
                                gitlabCommitStatus(name: "Test-Mono-TDD-Band40") {
463 464 465 466 467
                                    build job: 'eNB-CI-TDD-Band40-B210',
                                       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)),
468 469
                                           booleanParam(name: 'eNB_mergeRequest', value: true),
                                           string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
470 471 472
                                       ]
                                }
                            } else {
473
                                gitlabCommitStatus(name: "Test-Mono-TDD-Band40") {
474 475 476 477 478 479 480
                                    build job: 'eNB-CI-TDD-Band40-B210',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
481 482
                                }
                            }
483 484 485 486
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
487
                        // slave job. The only drop-back is that we may retrieve the HTML report of a previous build
488 489 490 491 492 493 494 495 496
                        always {
                            script {
                                if (!fileExists('test_results-eNB-CI-TDD-Band40-B210.html')) {
                                    copyArtifacts(projectName: 'eNB-CI-TDD-Band40-B210',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-eNB-CI-TDD-Band40-B210.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-eNB-CI-TDD-Band40-B210.html"
                                        archiveArtifacts artifacts: 'test_results-eNB-CI-TDD-Band40-B210.html'
497 498 499 500
                                    }
                                }
                            }
                        }
501 502 503 504 505
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
506 507 508 509 510 511 512 513 514 515 516 517
                    }
                }
                stage ("Test IF4p5 - FDD - Band 7 - B210") {
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
                                gitlabCommitStatus(name: "Test-IF4p5-FDD-Band7") {
                                    build job: 'eNB-CI-IF4p5-FDD-Band7-B210',
                                       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)),
518 519
                                           booleanParam(name: 'eNB_mergeRequest', value: true),
                                           string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
520 521 522 523 524 525 526 527 528 529 530
                                       ]
                                }
                            } else {
                                gitlabCommitStatus(name: "Test-IF4p5-FDD-Band7") {
                                    build job: 'eNB-CI-IF4p5-FDD-Band7-B210',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
531 532
                                }
                            }
533 534 535 536
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
537
                        // slave job.  The only drop-back is that we may retrieve the HTML report of a previous build
538 539 540 541 542 543 544 545 546
                        always {
                            script {
                                if (!fileExists('test_results-eNB-CI-IF4p5-FDD-Band7-B210.html')) {
                                    copyArtifacts(projectName: 'eNB-CI-IF4p5-FDD-Band7-B210',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-eNB-CI-IF4p5-FDD-Band7-B210.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-eNB-CI-IF4p5-FDD-Band7-B210.html"
                                        archiveArtifacts artifacts: 'test_results-eNB-CI-IF4p5-FDD-Band7-B210.html'
547 548 549 550
                                    }
                                }
                            }
                        }
551 552 553 554 555
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
556 557 558 559 560 561 562 563 564 565 566 567
                    }
                }
                stage ("Test IF4p5 - TDD - Band 40 - B210") {
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
                                gitlabCommitStatus(name: "Test-IF4p5-TDD-Band40") {
                                    build job: 'eNB-CI-IF4p5-TDD-Band40-B210',
                                       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)),
568 569
                                           booleanParam(name: 'eNB_mergeRequest', value: true),
                                           string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
570 571 572 573 574 575 576 577 578 579 580
                                       ]
                                }
                            } else {
                                gitlabCommitStatus(name: "Test-IF4p5-TDD-Band40") {
                                    build job: 'eNB-CI-IF4p5-TDD-Band40-B210',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
581 582
                                }
                            }
583 584 585 586
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
587
                        // slave job. The only drop-back is that we may retrieve the HTML report of a previous build
588 589 590 591 592 593 594 595 596
                        always {
                            script {
                                if (!fileExists('test_results-eNB-CI-IF4p5-TDD-Band40-B210.html')) {
                                    copyArtifacts(projectName: 'eNB-CI-IF4p5-TDD-Band40-B210',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-eNB-CI-IF4p5-TDD-Band40-B210.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-eNB-CI-IF4p5-TDD-Band40-B210.html"
                                        archiveArtifacts artifacts: 'test_results-eNB-CI-IF4p5-TDD-Band40-B210.html'
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
597 598 599 600
                                    }
                                }
                            }
                        }
601 602 603 604 605
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
606
                    }
607
                }
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
                stage ("Test MONOLITHIC - FDD - Band 13 - B210") {
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
                                gitlabCommitStatus(name: "Test-Mono-FDD-Band13") {
                                    build job: 'eNB-CI-MONO-FDD-Band13-B210',
                                       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))
                                       ]
                                }
                            } else {
                                gitlabCommitStatus(name: "Test-Mono-FDD-Band13") {
                                    build job: 'eNB-CI-MONO-FDD-Band13-B210',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
                                }
                            }
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
637
                        // slave job. The only drop-back is that we may retrieve the HTML report of a previous build
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
                        always {
                            script {
                                if (!fileExists('test_results-eNB-CI-MONO-FDD-Band13-B210.html')) {
                                    copyArtifacts(projectName: 'eNB-CI-MONO-FDD-Band13-B210',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-eNB-CI-MONO-FDD-Band13-B210.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-eNB-CI-MONO-FDD-Band13-B210.html"
                                        archiveArtifacts artifacts: 'test_results-eNB-CI-MONO-FDD-Band13-B210.html'
                                    }
                                }
                            }
                        }
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
                    }
                }
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
                stage ("Test OAI UE Sniffing - FDD - Band 20 - B200") {
                    steps {
                        script {
                            if ("MERGE".equals(env.gitlabActionType)) {
                                //gitlabCommitStatus(name: "Test-OAI-UE-FDD-Band20") {
                                    build job: 'UE-CI-FDD-Band20-B200',
                                       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))
                                       ]
                                //}
                            } else {
                                //gitlabCommitStatus(name: "Test-OAI-UE-FDD-Band20") {
                                    build job: 'UE-CI-FDD-Band20-B200',
                                       parameters: [
                                           string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
                                           string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
                                           string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
                                           booleanParam(name: 'eNB_mergeRequest', value: false)
                                       ]
                                //}
                            }
                        }
                    }
                    post {
                        // In case of any non-success, we are retrieving the HTML report of the last completed
Raphael Defosseux's avatar
Raphael Defosseux committed
687
                        // slave job. The only drop-back is that we may retrieve the HTML report of a previous build
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
                        always {
                            script {
                                if (!fileExists('test_results-UE-CI-FDD-Band20-B200.html')) {
                                    copyArtifacts(projectName: 'UE-CI-FDD-Band20-B200',
                                                  filter: 'test_results*.html',
                                                  selector: lastCompleted())
                                    if (fileExists('test_results-UE-CI-FDD-Band20-B200.html')) {
                                        sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_results-UE-CI-FDD-Band20-B200.html"
                                        archiveArtifacts artifacts: 'test_results-UE-CI-FDD-Band20-B200.html'
                                    }
                                }
                            }
                        }
                        failure {
                            script {
                                currentBuild.result = 'FAILURE'
                            }
                        }
                    }
                }
Raphael Defosseux's avatar
Raphael Defosseux committed
708 709 710 711 712
            }
            post {
                always {
                    script {
                        dir ('archives') {
713
                            sh "if [ -d basic_sim/test ] || [ -d phy_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi"
Raphael Defosseux's avatar
Raphael Defosseux committed
714 715 716
                        }
                        if(fileExists('archives/vm_tests_logs.zip')) {
                            archiveArtifacts artifacts: 'archives/vm_tests_logs.zip'
717
                            if ("MERGE".equals(env.gitlabActionType)) {
718
                                sh "./ci-scripts/oai-ci-vm-tool report-test --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
719
                            } else {
720
                                sh "./ci-scripts/oai-ci-vm-tool report-test --workspace $WORKSPACE --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger push --branch ${GIT_BRANCH} --commit ${GIT_COMMIT}"
721 722
                            }
                            if(fileExists('test_simulator_results.html')) {
723
                                sh "sed -i -e 's#Build-ID: ${BUILD_ID}#Build-ID: <a href=\"${BUILD_URL}\">${BUILD_ID}</a>#' -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' test_simulator_results.html"
724 725
                                archiveArtifacts artifacts: 'test_simulator_results.html'
                            }
Raphael Defosseux's avatar
Raphael Defosseux committed
726 727 728 729 730
                        }
                    }
                }
            }
        }
Raphael Defosseux's avatar
Raphael Defosseux committed
731 732
        stage ("Destroy all Virtual Machines") {
            steps {
733
                sh "./ci-scripts/oai-ci-vm-tool destroy --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
Raphael Defosseux's avatar
Raphael Defosseux committed
734 735
            }
        }
736 737 738
    }
    post {
        always {
739
            script {
Raphael Defosseux's avatar
Raphael Defosseux committed
740
                // Stage destroy may not be run if error in previous stage
741
                sh "./ci-scripts/oai-ci-vm-tool destroy --job-name ${JOB_NAME} --build-id ${BUILD_ID}"
Raphael Defosseux's avatar
Raphael Defosseux committed
742 743
                emailext attachmentsPattern: '*results*.html',
                     body: '''Hi,
Raphael Defosseux's avatar
Raphael Defosseux committed
744

745 746 747
Here are attached HTML report files for $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!

Regards,
Raphael Defosseux's avatar
Raphael Defosseux committed
748
OAI CI Team''',
749 750
                     replyTo: 'no-reply@openairinterface.org',
                     subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!',
Raphael Defosseux's avatar
Raphael Defosseux committed
751
                     to: gitCommitAuthorEmailAddr
752 753 754 755

                if (fileExists('.git/CI_COMMIT_MSG')) {
                    sh "rm -f .git/CI_COMMIT_MSG"
                }
756
            }
757 758 759
        }
        success {
            script {
760
                def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ")"
761 762 763
                if ("MERGE".equals(env.gitlabActionType)) {
                    echo "This is a MERGE event"
                    addGitLabMRComment comment: message
764
                    def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
765
                    sendSocialMediaMessage('ci-enb', 'good', message2)
766
                } else {
767
                    sendSocialMediaMessage('ci-enb', 'good', message)
768 769 770 771 772
                }
            }
        }
        failure {
            script {
773
                def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ")"
774 775 776
                if ("MERGE".equals(env.gitlabActionType)) {
                    echo "This is a MERGE event"
                    addGitLabMRComment comment: message
777
                    def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
778
                    sendSocialMediaMessage('ci-enb', 'danger', message2)
779
                } else {
780
                    sendSocialMediaMessage('ci-enb', 'danger', message)
781 782 783 784 785
                }
            }
        }
    }
}