Something went wrong on our end
-
Raphael Defosseux authored
Signed-off-by:
Raphael Defosseux <raphael.defosseux@eurecom.fr>
Raphael Defosseux authoredSigned-off-by:
Raphael Defosseux <raphael.defosseux@eurecom.fr>
Jenkinsfile-GitLab-Tutorial-Check 17.99 KiB
#!/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
*/
// Location of the CN executor node
def cn_ci_host = params.Host_CN_CI_Server
def upstreamEvent = false
// for lock
def cn_ci_resource = params.DockerContainers
// Default tags / branches --> could be passed on by upstream job
def nrfTag = params.nrfTag
def nrfBranch = params.nrfBranch
def amfTag = params.amfTag
def amfBranch = params.amfBranch
def smfTag = params.smfTag
def smfBranch = params.smfBranch
def spgwuTag = params.spgwuTag
def spgwuBranch = params.spgwuBranch
def ausfTag = params.ausfTag
def ausfBranch = params.ausfBranch
def udmTag = params.udmTag
def udmBranch = params.udmBranch
def udrTag = params.udrTag
def udrBranch = params.udrBranch
def nssfTag = params.nssfTag
def nssfBranch = params.nssfBranch
def upfVppTag = params.upfVppTag
def upfVppBranch = params.upfVppTag
// means to shorten the pipeline
def run_mini_gnbsim = true
def run_static_ue_ip = true
def run_vpp_upf = true
def run_slicing_w_nssf = true
//-------------------------------------------------------------------------------
// Pipeline start
pipeline {
agent {
label cn_ci_host
}
options {
disableConcurrentBuilds()
timestamps()
ansiColor('xterm')
lock(cn_ci_resource)
}
stages {
stage ('Verify Parameters') {
steps {
script {
echo '\u2705 \u001B[32mVerify Parameters\u001B[0m'
JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"'
JOB_TIMESTAMP = JOB_TIMESTAMP.trim()
echo "Node is ${NODE_NAME}"
// Find out the cause of the trigger
for (cause in currentBuild.getBuildCauses()) {
if (cause.toString() ==~ /.*UpstreamCause.*/) {
upstreamEvent = true
}
}
if (upstreamEvent) {
if (params.NRF_TAG != null) {
nrfTag = params.NRF_TAG
echo "Upstream Job passed NRF_TAG to use: ${nrfTag}"
run_mini_gnbsim = true
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.NRF_BRANCH != null) {
nrfBranch = params.NRF_BRANCH
echo "Upstream Job passed NRF_BRANCH to use: ${nrfBranch}"
}
if (params.AMF_TAG != null) {
amfTag = params.AMF_TAG
echo "Upstream Job passed AMF_TAG to use: ${amfTag}"
run_mini_gnbsim = true
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.AMF_BRANCH != null) {
amfBranch = params.AMF_BRANCH
echo "Upstream Job passed AMF_BRANCH to use: ${amfBranch}"
}
if (params.SMF_TAG != null) {
smfTag = params.SMF_TAG
echo "Upstream Job passed SMF_TAG to use: ${smfTag}"
run_mini_gnbsim = true
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.SMF_BRANCH != null) {
smfBranch = params.SMF_BRANCH
echo "Upstream Job passed SMF_BRANCH to use: ${smfBranch}"
}
if (params.SPGWU_TAG != null) {
spgwuTag = params.SPGWU_TAG
echo "Upstream Job passed SPGWU_TAG to use: ${spgwuTag}"
run_mini_gnbsim = true
run_static_ue_ip = true
run_vpp_upf = false
run_slicing_w_nssf = true
}
if (params.SPGWU_BRANCH != null) {
spgwuBranch = params.SPGWU_BRANCH
echo "Upstream Job passed SPGWU_BRANCH to use: ${spgwuBranch}"
}
if (params.AUSF_TAG != null) {
ausfTag = params.AUSF_TAG
echo "Upstream Job passed AUSF_TAG to use: ${ausfTag}"
run_mini_gnbsim = false
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.AUSF_BRANCH != null) {
ausfBranch = params.AUSF_BRANCH
echo "Upstream Job passed AUSF_BRANCH to use: ${ausfBranch}"
}
if (params.UDM_TAG != null) {
udmTag = params.UDM_TAG
echo "Upstream Job passed UDM_TAG to use: ${udmTag}"
run_mini_gnbsim = false
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.UDM_BRANCH != null) {
udmBranch = params.UDM_BRANCH
echo "Upstream Job passed UDM_BRANCH to use: ${udmBranch}"
}
if (params.UDR_TAG != null) {
udrTag = params.UDR_TAG
echo "Upstream Job passed UDR_TAG to use: ${udrTag}"
run_mini_gnbsim = false
run_static_ue_ip = true
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.UDR_BRANCH != null) {
udrBranch = params.UDR_BRANCH
echo "Upstream Job passed UDR_BRANCH to use: ${udrBranch}"
}
if (params.NSSF_TAG != null) {
nssfTag = params.NSSF_TAG
echo "Upstream Job passed NSSF_TAG to use: ${nssfTag}"
run_mini_gnbsim = false
run_static_ue_ip = false
run_vpp_upf = false
run_slicing_w_nssf = true
}
if (params.NSSF_BRANCH != null) {
nssfBranch = params.NSSF_BRANCH
echo "Upstream Job passed NSSF_BRANCH to use: ${nssfBranch}"
}
if (params.UPF_VPP_TAG != null) {
upfVppTag = params.UPF_VPP_TAG
echo "Upstream Job passed UPF_VPP_TAG to use: ${upfVppTag}"
run_mini_gnbsim = false
run_static_ue_ip = false
run_vpp_upf = true
run_slicing_w_nssf = true
}
if (params.UPF_VPP_BRANCH != null) {
upfVppBranch = params.UPF_VPP_BRANCH
echo "Upstream Job passed UPF_VPP_BRANCH to use: ${upfVppBranch}"
}
sh "git clean -x -d -f > /dev/null 2>&1"
sh "git fetch --prune > /dev/null 2>&1"
sh 'git checkout -f ' + upstreamTagToUse
sh "mkdir -p archives"
} else {
sh "git clean -x -d -f > /dev/null 2>&1"
sh "mkdir -p archives"
}
// Verify that the images are available
try {
sh 'echo "OAI_NRF_TAG: oai-nrf:' + nrfTag +'" > archives/oai_nrf_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-nrf:' + nrfTag + ' >> archives/oai_nrf_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-nrf:' + nrfTag + ' >> archives/oai_nrf_image_info.log'
} catch (Exception e) {
error "OAI NRF Image tag to test does not exist!"
}
try {
sh 'echo "OAI_AMF_TAG: oai-amf:' + amfTag +'" > archives/oai_amf_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-amf:' + amfTag + ' >> archives/oai_amf_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-amf:' + amfTag + ' >> archives/oai_amf_image_info.log'
} catch (Exception e) {
error "OAI AMF Image tag to test does not exist!"
}
try {
sh 'echo "OAI_SMF_TAG: oai-smf:' + smfTag +'" > archives/oai_smf_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-smf:' + smfTag + ' >> archives/oai_smf_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-smf:' + smfTag + ' >> archives/oai_smf_image_info.log'
} catch (Exception e) {
error "OAI SMF Image tag to test does not exist!"
}
try {
sh 'echo "OAI_SPGWU_TAG: oai-spgwu-tiny:' + spgwuTag +'" > archives/oai_spgwu_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-spgwu-tiny:' + spgwuTag + ' >> archives/oai_spgwu_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-spgwu-tiny:' + spgwuTag + ' >> archives/oai_spgwu_image_info.log'
} catch (Exception e) {
error "OAI SPGW-U-Tiny Image tag to test does not exist!"
}
try {
sh 'echo "OAI_AUSF_TAG: oai-ausf:' + ausfTag +'" > archives/oai_ausf_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-ausf:' + ausfTag + ' >> archives/oai_ausf_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-ausf:' + ausfTag + ' >> archives/oai_ausf_image_info.log'
} catch (Exception e) {
error "OAI AUSF Image tag to test does not exist!"
}
try {
sh 'echo "OAI_UDM_TAG: oai-udm:' + udmTag +'" > archives/oai_udm_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-udm:' + udmTag + ' >> archives/oai_udm_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-udm:' + udmTag + ' >> archives/oai_udm_image_info.log'
} catch (Exception e) {
error "OAI UDM Image tag to test does not exist!"
}
try {
sh 'echo "OAI_UDR_TAG: oai-udr:' + udrTag +'" > archives/oai_udr_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-udr:' + udrTag + ' >> archives/oai_udr_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-udr:' + udrTag + ' >> archives/oai_udr_image_info.log'
} catch (Exception e) {
error "OAI UDR Image tag to test does not exist!"
}
try {
sh 'echo "OAI_NSSF_TAG: oai-nssf:' + nssfTag +'" > archives/oai_nssf_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-nssf:' + nssfTag + ' >> archives/oai_nssf_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-nssf:' + nssfTag + ' >> archives/oai_nssf_image_info.log'
} catch (Exception e) {
error "OAI NSSF Image tag to test does not exist!"
}
try {
sh 'echo "OAI_UPF_VPP_TAG: oai-upf-vpp:' + upfVppTag +'" > archives/oai_upf_vpp_image_info.log'
sh 'docker image inspect --format=\'Size = {{.Size}} bytes\' oai-upf-vpp:' + upfVppTag + ' >> archives/oai_upf_vpp_image_info.log'
sh 'docker image inspect --format=\'Date = {{.Created}}\' oai-upf-vpp:' + upfVppTag + ' >> archives/oai_upf_vpp_image_info.log'
} catch (Exception e) {
error "OAI UPF-VPP Image tag to test does not exist!"
}
}
}
}
stage ('Check Minimalist Deployment Tutorial') {
when { expression {run_mini_gnbsim} }
steps {
script {
updateDockerCompose('docker-compose/docker-compose-mini-nrf.yaml', amfTag, nrfTag, smfTag, spgwuTag, ausfTag, udmTag, udrTag, nssfTag, upfVppTag)
dir ('ci-scripts') {
// Tee will make the command always pass
// Please use the same log name as the folder used in the tutorial
sh 'python3 ./checkTutorial.py --tutorial DEPLOY_SA5G_WITH_GNBSIM.md | tee ../archives/mini-gnbsim.log'
}
// Checking if FAIL appears
try {
sh 'grep -L FAIL archives/mini-gnbsim.log > /dev/null'
currentBuild.result = 'FAILURE'
echo "Minimalist gnbsim Tutorial FAILED"
} catch (Exception e) {
echo "Minimalist gnbsim Tutorial PASSED"
}
archivesArtifacts('docker-compose/docker-compose-mini-nrf.yaml', 'mini-gnbsim')
cleanUpDockerCompose('docker-compose/docker-compose-mini-nrf.yaml')
}
}
}
stage ('Check Static UE IP Tutorial') {
when { expression {run_static_ue_ip} }
steps {
script {
updateDockerCompose('docker-compose/docker-compose-basic-nrf.yaml', amfTag, nrfTag, smfTag, spgwuTag, ausfTag, udmTag, udrTag, nssfTag, upfVppTag)
dir ('ci-scripts') {
// Tee will make the command always pass
// Please use the same log name as the folder used in the tutorial
sh 'python3 ./checkTutorial.py --tutorial DEPLOY_SA5G_BASIC_STATIC_UE_IP.md | tee ../archives/static-ue-ip.log'
}
// Checking if FAIL appears
try {
sh 'grep -L FAIL archives/static-ue-ip.log > /dev/null'
currentBuild.result = 'FAILURE'
echo "Static UE IP Tutorial FAILED"
} catch (Exception e) {
echo "Static UE IP Tutorial PASSED"
}
archivesArtifacts('docker-compose/docker-compose-basic-nrf.yaml', 'static-ue-ip')
cleanUpDockerCompose('docker-compose/docker-compose-basic-nrf.yaml')
}
}
}
stage ('Check UPF-VPP Tutorial') {
when { expression {run_vpp_upf} }
steps {
script {
updateDockerCompose('docker-compose/docker-compose-basic-vpp-nrf.yaml', amfTag, nrfTag, smfTag, spgwuTag, ausfTag, udmTag, udrTag, nssfTag, upfVppTag)
dir ('ci-scripts') {
// Tee will make the command always pass
// Please use the same log name as the folder used in the tutorial
sh 'python3 ./checkTutorial.py --tutorial DEPLOY_SA5G_WITH_VPP_UPF.md | tee ../archives/vpp-upf-gnbsim.log'
}
// Checking if FAIL appears
try {
sh 'grep -L FAIL archives/vpp-upf-gnbsim.log > /dev/null'
currentBuild.result = 'FAILURE'
echo "UPF-VPP Tutorial FAILED"
} catch (Exception e) {
echo "UPF-VPP Tutorial PASSED"
}
archivesArtifacts('docker-compose/docker-compose-basic-vpp-nrf.yaml', 'vpp-upf-gnbsim')
cleanUpDockerCompose('docker-compose/docker-compose-basic-vpp-nrf.yaml')
}
}
}
stage ('Check NSSF-Slicing Tutorial') {
when { expression {run_slicing_w_nssf} }
steps {
script {
updateDockerCompose('docker-compose/docker-compose-slicing-basic-nrf.yaml', amfTag, nrfTag, smfTag, spgwuTag, ausfTag, udmTag, udrTag, nssfTag, upfVppTag)
dir ('ci-scripts') {
// Tee will make the command always pass
// Please use the same log name as the folder used in the tutorial
sh 'python3 ./checkTutorial.py --tutorial DEPLOY_SA5G_SLICING.md | tee ../archives/slicing-with-nssf.log'
}
// Checking if FAIL appears
try {
sh 'grep -L FAIL archives/slicing-with-nssf.log > /dev/null'
currentBuild.result = 'FAILURE'
echo "NSSF-Slicing Tutorial FAILED"
} catch (Exception e) {
echo "NSSF-Slicing Tutorial PASSED"
}
archivesArtifacts('docker-compose/docker-compose-slicing-basic-nrf.yaml', 'slicing-with-nssf')
cleanUpDockerCompose('docker-compose/docker-compose-slicing-basic-nrf.yaml')
}
}
}
}
post {
always {
script {
// Zipping all archived log files
sh "zip -r -qq cn5g_fed_tutorials_logs.zip archives"
if (fileExists('cn5g_fed_tutorials_logs.zip')) {
archiveArtifacts artifacts: 'cn5g_fed_tutorials_logs.zip'
}
sh 'python3 ./ci-scripts/checkTutorialHtmlReport.py --job_name=' + JOB_NAME + ' --job_id=' + BUILD_ID + ' --job_url=' + BUILD_URL
if (fileExists('test_results_oai_cn5g_tutorials.html')) {
archiveArtifacts artifacts: 'test_results_oai_cn5g_tutorials.html'
}
}
}
}
}
def updateDockerCompose(filename, lAmfTag, lNrfTag, lSmfTag, lSpgwuTag, lAusfTag, lUdmTag, lUdrTag, lNssfTag, lUpfVppTag) {
sh 'sed -i -e "s@oai-amf:latest@oai-amf:' + lAmfTag + '@" ' + filename
sh 'sed -i -e "s@oai-nrf:latest@oai-nrf:' + lNrfTag + '@" ' + filename
sh 'sed -i -e "s@oai-smf:latest@oai-smf:' + lSmfTag + '@" ' + filename
sh 'sed -i -e "s@oai-spgwu-tiny:latest@oai-spgwu-tiny:' + lSpgwuTag + '@" ' + filename
sh 'sed -i -e "s@oai-ausf:latest@oai-ausf:' + lAusfTag + '@" ' + filename
sh 'sed -i -e "s@oai-udm:latest@oai-udm:' + lUdmTag + '@" ' + filename
sh 'sed -i -e "s@oai-udr:latest@oai-udr:' + lUdrTag + '@" ' + filename
sh 'sed -i -e "s@oai-nssf:latest@oai-nssf:' + lNssfTag + '@" ' + filename
sh 'sed -i -e "s@oai-upf-vpp:latest@oai-upf-vpp:' + lUpfVppTag + '@" ' + filename
// Using the develop variant of gnbsim
sh 'sed -i -e "s@gnbsim:latest@gnbsim:develop@" docker-compose/docker-compose-gnbsim*.y*ml docker-compose/docker-compose*ransim.y*ml'
}
def archivesArtifacts(filename,folder) {
sh 'cp -Rf /tmp/oai/' + folder + ' archives || true'
// Making a copy of the docker-compose for debugging
sh 'cp ' + filename + ' archives/' + folder + ' || true'
}
def cleanUpDockerCompose(filename) {
sh 'git checkout -- ' + filename
sh 'git checkout -- docker-compose/docker-compose-gnbsim*.y*ml docker-compose/docker-compose*ransim.y*ml'
}