Jenkinsfile-tmp-ran 17.1 KB
Newer Older
1
//
2 3 4 5 6 7
// Comments

pipeline {
    // The node should be selected with a 'label' parameter
    // trying to use NodeLabel plugin to pass it, currently failing to do so
    agent {
8
        label 'starsky'
9 10 11 12
    }
    options {
        disableConcurrentBuilds()
        timestamps()
13
        ansiColor('xterm')
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    }
    // 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 {
        //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')
        string(name: 'eNB_SourceCodePath', defaultValue: '/home/starsky/CI-enb', description: 'Full path of eNB source code')

        //EPC parameters
        string(name: 'EPC_IPAddress', defaultValue: '192.168.XX.XX', description: 'IP Address of EPC')
        string(name: 'EPC_Type', defaultValue: 'OAI', description: 'EPC type: OAI or ltebox')
        credentials(name: 'EPC_Credentials', defaultValue: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', credentialType: "Username with password", required: true, description: 'Credentials for EPC')
        string(name: 'EPC_SourceCodePath', defaultValue: '/home/nano/CI_oai-cn/openair-cn', description: 'Full path of EPC source code')

        //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 {
                    def allParametersPresent = true
                    if (params.CI_MASTER_NODE != null) {
                        echo "eNB CI parameter node :   $params.CI_MASTER_NODE"
                    } else {
                        echo "eNB CI master node    :   $NODE_NAME"
                    }

                    if (params.eNB_IPAddress == null) {
                        allParametersPresent = false
                    }
                    if (params.eNB_SourceCodePath == null) {
                        allParametersPresent = false
                    }
                    if (params.eNB_Credentials == null) {
                        allParametersPresent = false
                    }

                    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"
                    }
                }
            }
        }
87
        stage ("Build eNB") {
88 89 90 91 92 93 94 95 96
            steps {
                script {
                    dir ('ci-scripts') {
                        try {
                            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']
                            ]) {
97 98 99 100 101 102 103 104 105 106 107 108 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
                                sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${GIT_URL} --eNBBranch=${GIT_BRANCH} --eNBCommitID=${GIT_COMMIT} --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=xml_files/build_enb_usrp_start_epc.xml"
                            }
                        } catch (Exception e) {
                            sh "./ci-scripts/fail.sh"
                            currentBuild.result = 'FAILURE'
                        }
                    }
                }
            }
        }
        stage ("Test eNB - Band 7 - USRP210 - 5MHz") {
            steps {
                script {
                    dir ('ci-scripts') {
                        try {
                            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']
                            ]) {
                                sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${GIT_URL} --eNBBranch=${GIT_BRANCH} --eNBCommitID=${GIT_COMMIT} --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=xml_files/enb_usrpB210_band7_50PRB.xml"
                            }
                        } catch (Exception e) {
                            //sh "./ci-scripts/fail.sh"
                            currentBuild.result = 'FAILURE'
                        }
                    }
                }
            }
        }
        stage ("Terminate All") {
            steps {
                script {
                    dir ('ci-scripts') {
                        try {
                            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']
                            ]) {
                                sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${GIT_URL} --eNBBranch=${GIT_BRANCH} --eNBCommitID=${GIT_COMMIT} --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=xml_files/terminate_epc.xml"
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
                            }
                        } catch (Exception e) {
                            //sh "./ci-scripts/fail.sh"
                            currentBuild.result = 'FAILURE'
                        }
                    }
                }
            }
        }
        stage('Log Collection') {
            parallel {
                stage('Log Collection (eNB)') {
                    steps {
                        script {
                            dir ('ci-scripts') {
                                withCredentials([
                                     [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password']
                                ]) {
                                    sh "python3 main.py --mode=LogCollectBuild --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}"
                                    sh "python3 main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}"
                                    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"
                                    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"
                                    // No need to remove since we are wiping out the folder on the eNB server during build
                                    // sh "sshpass -p \'${eNB_Password}\' ssh -t -t -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress} 'cd ${eNB_SourceCodePath}; cd cmake_targets; if [ -e build.log.zip ]; then rm build.log.zip; fi;'"
                                    // sh "sshpass -p \'${eNB_Password}\' ssh -t -t -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress} 'cd ${eNB_SourceCodePath}; cd cmake_targets; if [ -e enb.log.zip ]; then rm enb.log.zip; fi;'"
                                    if(fileExists("build.log.${env.BUILD_ID}.zip")) {
                                        archiveArtifacts "build.log.${env.BUILD_ID}.zip"
                                        // Same thing here, no need to remove.
                                        // SCM folder is wiped out at build start on node
                                        // sh "rm build.log.${env.BUILD_ID}.zip"
                                    }
                                    if(fileExists("enb.log.${env.BUILD_ID}.zip")) {
                                        archiveArtifacts "enb.log.${env.BUILD_ID}.zip"
                                        // Same thing here, no need to remove.
                                        // SCM folder is wiped out at build start on node
                                        // sh "rm enb.log.${env.BUILD_ID}.zip"
                                    }
                                }
                            }
                        }
                    }
                }
                stage('Log Collection (EPC)') {
                    steps {
                        script {
                            dir ('ci-scripts') {
                                withCredentials([
                                     [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password']
                                ]) {
                                    sh "python3 main.py --mode=LogCollectSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type} "
                                    sh "python3 main.py --mode=LogCollectMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type} "
                                    sh "python3 main.py --mode=LogCollectHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type} "
190 191 192 193 194
                                    sh "python3 main.py --mode=LogCollectPing --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type} "

                                    sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/*.log.zip . || true"
                                    if(fileExists("spgw.log.zip")) {
                                        sh "mv spgw.log.zip ./spgw.log.${env.BUILD_ID}.zip"
195 196 197
                                        archiveArtifacts "spgw.log.${env.BUILD_ID}.zip"
                                        sh "rm spgw.log.${env.BUILD_ID}.zip"
                                    }
198 199
                                    if(fileExists("mme.log.zip")) {
                                        sh "mv mme.log.zip ./mme.log.${env.BUILD_ID}.zip"
200 201 202
                                        archiveArtifacts "mme.log.${env.BUILD_ID}.zip"
                                        sh "rm mme.log.${env.BUILD_ID}.zip"
                                    }
203 204
                                    if(fileExists("hss.log.zip")) {
                                        sh "mv hss.log.zip ./hss.log.${env.BUILD_ID}.zip"
205 206 207
                                        archiveArtifacts "hss.log.${env.BUILD_ID}.zip"
                                        sh "rm hss.log.${env.BUILD_ID}.zip"
                                    }
208 209 210 211 212
                                    if(fileExists("ping.log.zip")) {
                                        sh "mv ping.log.zip ./ping.log.${env.BUILD_ID}.zip"
                                        archiveArtifacts "ping.log.${env.BUILD_ID}.zip"
                                        sh "rm ping.log.${env.BUILD_ID}.zip"
                                    }
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    post {
        always {
            echo "Archiving Jenkins console log"
            // Not working in Eurecom environment
            /*
            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"
            script {
                if(fileExists("consoleText.log.${env.BUILD_ID}.zip")) {
                    archiveArtifacts "consoleText.log.${env.BUILD_ID}.zip"
                    sh "rm consoleText.log.${env.BUILD_ID}.zip"
                }
            }
            */
        }
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
        failure {
            script {
                dir ('ci-scripts') {
                    try {
                        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']
                        ]) {
                            sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${GIT_URL} --eNBBranch=${GIT_BRANCH} --eNBCommitID=${GIT_COMMIT} --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=xml_files/terminate_epc.xml"
                        }
                    } catch (Exception e) {
                        echo "could not properly terminate everything"
                    }
                }
            }
        }
254 255
    }
}