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-Docker-Check 8.89 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
*/
//-------------------------------------------------------------------------------
// 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
}
}
}
// Location of the CN executor node
def cn_ci_host = params.Host_CN_CI_Server
// for lock
def cn_ci_resource = params.DockerContainers
//-------------------------------------------------------------------------------
// 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()
sh "git clean -x -d -f > /dev/null 2>&1"
sh 'git log -n1'
if (params.CheckAnotherBranch != null) {
if (params.CheckAnotherBranch) {
if (params.BranchToCheck != null) {
sh 'git checkout '+ params.BranchToCheck
sh 'git log -n1'
}
}
}
sh "mkdir -p archives/cn5g"
sh "mkdir -p archives/cn5gwithnoNRF"
sh "mkdir -p archives/gnbsim"
}
}
}
stage ('Deploy Whole 5G Core Network with NRF') {
steps {
script {
echo '\u2705 \u001B[32mDeploy CN5G using Docker-Compose with NRF\u001B[0m'
dir('docker-compose') {
sh 'sed -i -e "s@latest@develop@g" docker-compose.yaml'
sh 'docker-compose -f docker-compose.yaml up -d > ../archives/cn5g/compose_5gcn_up.log 2>&1'
sh 'sleep 100'
// Do a check on number of healthy containers
// 5 == mysql + nrf + amf + smf + upf(spgwu-tiny)
ret = sh returnStdout: true, script: 'docker-compose ps -a | grep -v unhealthy | grep -c healthy || true'
ret = ret.trim()
if (ret != '5') {
error "Deployment went wrong!"
}
}
}
}
post {
always {
script {
sh 'docker logs oai-nrf > archives/cn5g/oai_nrf.log 2>&1 || true'
sh 'docker logs oai-amf > archives/cn5g/oai_amf.log 2>&1 || true'
sh 'docker logs oai-smf > archives/cn5g/oai_smf.log 2>&1 || true'
sh 'docker logs oai-spgwu > archives/cn5g/oai_spgwu.log 2>&1 || true'
}
}
success {
script {
sh 'echo "DEPLOYMENT: OK"'
}
}
unsuccessful {
script {
sh 'echo "DEPLOYMENT: KO"'
}
}
}
}
stage ('Undeploy 5G-CN with NRF') {
steps {
script {
echo '\u2705 \u001B[32mUn-Deploy CN5G with NRF\u001B[0m'
dir('docker-compose') {
sh 'docker-compose down > ../archives/cn5g/compose_normal_down.log 2>&1'
}
}
}
}
stage ('Deploy Whole 5G Core Network without NRF') {
steps {
script {
echo '\u2705 \u001B[32mDeploy CN5G using Docker-Compose without NRF\u001B[0m'
dir('docker-compose') {
sh 'sed -i -e "s@latest@develop@g" docker-compose-no-nrf.yaml'
sh 'docker-compose -f docker-compose-no-nrf.yaml up -d > ../archives/cn5gwithnoNRF/compose_5gcn_up.log 2>&1'
sh 'sleep 100'
// Do a check on number of healthy containers
// 4 == mysql + amf + smf + upf(spgwu-tiny)
ret = sh returnStdout: true, script: 'docker-compose -f docker-compose-no-nrf.yaml ps -a | grep -v unhealthy | grep -c healthy || true'
ret = ret.trim()
if (ret != '4') {
error "Deployment went wrong without NRF!"
}
}
}
}
post {
always {
script {
sh 'docker logs oai-amf > archives/cn5gwithnoNRF/oai_amf.log 2>&1 || true'
sh 'docker logs oai-smf > archives/cn5gwithnoNRF/oai_smf.log 2>&1 || true'
sh 'docker logs oai-spgwu > archives/cn5gwithnoNRF/oai_spgwu.log 2>&1 || true'
}
}
success {
script {
sh 'echo "DEPLOYMENT: OK without NRF"'
}
}
unsuccessful {
script {
dir('docker-compose') {
sh 'docker-compose -f docker-compose-no-nrf.yaml down || true'
}
sh 'echo "DEPLOYMENT: KO without NRF"'
}
}
}
}
stage ('Undeploy 5G-CN without NRF') {
steps {
script {
echo '\u2705 \u001B[32mUn-Deploy CN5G without NRF\u001B[0m'
dir('docker-compose') {
sh 'docker-compose -f docker-compose-no-nrf.yaml down > ../archives/cn5gwithnoNRF/compose_normal_down.log 2>&1'
}
}
}
}
stage ('gnbsim tutorial') {
steps {
script {
echo '\u2705 \u001B[32mDeploy CN5G using Docker-Compose with NRF\u001B[0m'
dir('docker-compose') {
sh 'docker-compose -f docker-compose.yaml up -d > ../archives/gnbsim/compose_5gcn_up.log 2>&1'
sh 'sleep 100'
// Do a check on number of healthy containers
// 5 == mysql + nrf + amf + smf + upf(spgwu-tiny)
ret = sh returnStdout: true, script: 'docker-compose ps -a | grep -v unhealthy | grep -c healthy || true'
ret = ret.trim()
if (ret != '5') {
error "Deployment went wrong!"
}
sh 'docker-compose -f docker-compose-gnbsim.yaml up -d gnbsim > ../archives/gnbsim/gnbsim_up.log 2>&1'
sh 'sleep 20'
// Do a check if gnbsim is healthy
ret = sh returnStdout: true, script: 'docker-compose -f docker-compose-gnbsim.yaml ps -a | grep -v unhealthy | grep -c healthy || true'
ret = ret.trim()
if (ret != '1') {
error "gnbsim deployment went wrong"
}
}
}
}
post {
always {
script {
sh 'docker logs oai-nrf > archives/gnbsim/oai_nrf.log 2>&1 || true'
sh 'docker logs oai-amf > archives/gnbsim/oai_amf.log 2>&1 || true'
sh 'docker logs oai-smf > archives/gnbsim/oai_smf.log 2>&1 || true'
sh 'docker logs oai-spgwu > archives/gnbsim/oai_spgwu.log 2>&1 || true'
sh 'docker logs gnbsim > archives/gnbsim/gnbsim.log 2>&1 || true'
}
}
success {
script {
sh 'echo "DEPLOYMENT: OK"'
}
}
unsuccessful {
script {
dir('docker-compose') {
sh 'docker-compose -f docker-compose-gnbsim.yaml down || true'
sh 'docker-compose down || true'
}
sh 'echo "DEPLOYMENT: KO"'
}
}
}
}
stage ('Un-deploy gnbsim tutorial') {
steps {
script {
dir('docker-compose') {
sh 'docker-compose -f docker-compose-gnbsim.yaml down > ../archives/gnbsim/gnbsim_down.log 2>&1'
sh 'docker-compose down >> ../archives/gnbsim/cn5g_down.log 2>&1'
}
}
}
}
}
post {
always {
script {
// Remove any leftover containers/networks
dir('docker-compose') {
sh 'docker-compose -f docker-compose-gnbsim.yaml down || true'
sh 'docker-compose down || true'
}
// Zipping all archived log files
sh "zip -r -qq cn5g_deploy_docker_logs.zip archives"
if (fileExists('cn5g_deploy_docker_logs.zip')) {
archiveArtifacts artifacts: 'cn5g_deploy_docker_logs.zip'
}
}
}
}
}