Commit 0da9c27b authored by Mohammed Ismail's avatar Mohammed Ismail

[CI] added rhel build

Signed-off-by: default avatarMohammed Ismail <mohammed.ismail@openairinterface.org>
parent da6976f8
......@@ -39,7 +39,7 @@ case "$OS_DISTRO" in
ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;;
esac
IS_CONTAINER=`egrep -c "docker|kubepods|podman" /proc/self/cgroup`
IS_CONTAINER=`egrep -c "docker|kubepods|podman|buildah|libpod" /proc/self/cgroup || true`
if [ $IS_CONTAINER -eq 0 ]
then
......
......@@ -240,6 +240,8 @@ install_nghttp2_from_git() {
binutils-devel \
autoconf \
automake \
$CMAKE \
make \
libtool \
pkg-config \
zlib-devel \
......
......@@ -28,10 +28,16 @@ def cn_ci_host = params.Host_CN_CI_Server
// for lock
def cn_ci_resource = params.DockerContainers
// Location of the 2nd CN executor
def new_host_flag = false
def new_host = ""
def new_host_user = ""
// Location of the Remote Ubuntu18 CN executor
def rem_u18_host_flag = false
def rem_u18_host = ""
def rem_u18_host_user = ""
// Location of the Remote RHEL CN executor
def rem_rhel_host_flag = false
def rem_rhel_host = ""
def rem_rhel_host_user = ""
def rem_rhel8_resource = params.PodmanContainers
// Tags/Branches to use
def nrf_tag = "develop"
......@@ -41,6 +47,9 @@ def nrf_branch = "develop"
// This base image is potentially subject to changes over time.
def NRF_BASE_IMAGE_TAG = params.NrfBaseImageTag
// Merge Request Link
def gitlabMergeRequestLink
//-------------------------------------------------------------------------------
// Pipeline start
pipeline {
......@@ -54,7 +63,8 @@ pipeline {
lock(cn_ci_resource)
gitLabConnection('OAI GitLab')
gitlabBuilds(builds: [
"Build NRF Image",
"Build U18 NRF Image",
"Build RHEL8 NRF Image",
"Static Code Analysis",
"Code Formatting Checker",
"Test with DsTester"
......@@ -72,23 +82,31 @@ pipeline {
JOB_TIMESTAMP = JOB_TIMESTAMP.trim()
if (params.Host_CN_CI_2nd_Server_Flag != null) {
new_host_flag = params.Host_CN_CI_2nd_Server_Flag
if (new_host_flag) {
new_host = params.Host_CN_CI_2nd_Server
new_host_user = params.Host_CN_CI_2nd_Server_Login
rem_u18_host_flag = params.Host_CN_CI_2nd_Server_Flag
if (rem_u18_host_flag) {
rem_u18_host = params.Host_CN_CI_2nd_Server
rem_u18_host_user = params.Host_CN_CI_2nd_Server_Login
echo "1st Node is ${NODE_NAME}"
echo "2nd Node is ${new_host}"
echo "2nd Node is ${rem_u18_host}"
} else {
echo "Node is ${NODE_NAME}"
echo "U18 Node is ${NODE_NAME}"
}
} else {
echo "Node is ${NODE_NAME}"
}
if (params.Remote_RHEL_Server_Flag != null) {
rem_rhel_host_flag = params.Remote_RHEL_Server_Flag
if (rem_rhel_host_flag) {
rem_rhel_host = params.Remote_RHEL_Server_Name
rem_rhel_host_user = params.Remote_RHEL_Server_Login
echo "RHEL Node is ${rem_rhel_host}"
}
}
echo "Git URL is ${GIT_URL}"
if ("MERGE".equals(env.gitlabActionType)) {
try {
myShCmd('docker image inspect --format=\'Size = {{.Size}} bytes\' oai-nrf-base:' + NRF_BASE_IMAGE_TAG, new_host_flag, new_host_user, new_host)
myShCmd('docker image inspect --format=\'Size = {{.Size}} bytes\' oai-nrf-base:' + NRF_BASE_IMAGE_TAG, rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) {
currentBuild.result = 'FAILURE'
echo '\u26D4 \u001B[31mBase Image does not exist\u001B[0m'
......@@ -103,12 +121,24 @@ pipeline {
script {
sh "git clean -x -d -f > /dev/null 2>&1"
if ("MERGE".equals(env.gitlabActionType)) {
gitlabMergeRequestLink = sh "curl --silent \"https://gitlab.eurecom.fr/api/v4/projects/oai%2Fcn5g%2Foai-cn5g-nrf/merge_requests/${env.gitlabMergeRequestIid}\" | jq .web_url | sed 's#\"##g'"
echo "========= THIS IS A MERGE REQUEST =========="
echo "MR ID is ${env.gitlabMergeRequestIid}"
echo "MR LINK is ${gitlabMergeRequestLink}"
echo "MR TITLE is ${env.gitlabMergeRequestTitle}"
gitCommitAuthorEmailAddr = env.gitlabUserEmail
echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
sh "git fetch --prune --unshallow"
shortenShaOne = sh returnStdout: true, script: 'git log -1 --pretty=format:"%h" ' + env.gitlabMergeRequestLastCommit
shortenShaOne = shortenShaOne.trim()
sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
sh "sleep 10"
nrf_tag = "ci-tmp"
rhel_nrf_tag = 'ci-tmp-pr-' + env.gitlabMergeRequestIid + '-' + shortenShaOne
nrf_branch = env.gitlabSourceBranch
echo "MR TAG is ${rhel_nrf_tag}"
} else {
echo "======== THIS IS A PUSH REQUEST ========"
echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}"
gitCommitAuthorEmailAddr = sh returnStdout: true, script: 'git log -n1 --pretty=format:%ae ${GIT_COMMIT}'
......@@ -118,13 +148,11 @@ pipeline {
}
sh "tar -cjhf /tmp/openair-nrf.tar.bz2 ."
sh "mv /tmp/openair-nrf.tar.bz2 ."
copyTo2ndServer('openair-nrf.tar.bz2', new_host_flag, new_host_user, new_host)
sh "mkdir -p archives"
if (new_host_flag) {
copyTo2ndServer('openair-nrf.tar.bz2', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
copyTo2ndServer('openair-nrf.tar.bz2', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
sh "mkdir -p archives/oai-nrf-cfg"
}
}
}
post {
failure {
script {
......@@ -137,43 +165,43 @@ pipeline {
}
stage('Build Core Network Function') {
parallel {
stage ('Build NRF Image') {
stage ('Build U18 NRF Image') {
steps {
script {
gitlabCommitStatus(name: "Build NRF Image") {
myShCmd('docker image prune --force', new_host_flag, new_host_user, new_host)
gitlabCommitStatus(name: "Build U18 NRF Image") {
myShCmd('docker image prune --force', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
if ("PUSH".equals(env.gitlabActionType)) {
// Currently this pipeline only runs for pushes to `develop` branch
// First clean image registry
try {
myShCmd('docker image rm oai-nrf:develop', new_host_flag, new_host_user, new_host)
myShCmd('docker image rm oai-nrf:develop', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) {
echo "Maybe a previous build went wrong"
}
// In case of push to `develop` branch we build from scratch
myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.ubuntu.18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/nrf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.ubuntu.18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/nrf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
if ("MERGE".equals(env.gitlabActionType)) {
try {
// Checking if the CI Base image is still there.
// If the inspect command fails, it's not there. If it passes, let remove tag.
myShCmd('docker image inspect oai-nrf-base:latest > /dev/null 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker rmi oai-nrf-base:latest', new_host_flag, new_host_user, new_host)
myShCmd('docker image inspect oai-nrf-base:latest > /dev/null 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker rmi oai-nrf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) {
echo 'No need to remove the CI base image'
}
// "latest" is the tag used in the docker file.
myShCmd('docker image tag oai-nrf-base:' + NRF_BASE_IMAGE_TAG + ' oai-nrf-base:latest', new_host_flag, new_host_user, new_host)
myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/nrf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker image tag oai-nrf-base:' + NRF_BASE_IMAGE_TAG + ' oai-nrf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/nrf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
myShCmd('docker image ls >> archives/nrf_docker_image_build.log', new_host_flag, new_host_user, new_host)
myShCmd('docker image ls >> archives/nrf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
}
post {
always {
script {
copyFrom2ndServer('archives/nrf_docker_image_build.log', 'archives', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/nrf_docker_image_build.log', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
success {
......@@ -184,32 +212,79 @@ pipeline {
}
}
}
stage ('Build RHEL8 NRF Image') {
when { expression {rem_rhel_host_flag} }
steps {
lock (rem_rhel8_resource) {
script {
gitlabCommitStatus(name: "Build RHEL8 NRF Image") {
if ("PUSH".equals(env.gitlabActionType)) {
// Currently this pipeline only runs for pushes to `develop` branch
// First clean image registry
try {
myShCmd('sudo podman image rm oai-nrf:develop || true', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
} catch (Exception e) {
echo "Maybe a previous build went wrong"
}
} else {
// In case we forgot during a previous run
myShCmd('sudo podman image rm oai-nrf:' + nrf_tag + ' || true', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Copy the RHEL Host certificates for building
myShCmd('mkdir -p tmp/ca tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('cp /etc/pki/entitlement/*pem tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.nrf.rhel8.2 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" . > archives/nrf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman image ls >> archives/nrf_podman_image_build.log', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('sudo podman image tag oai-nrf:' + nrf_tag + ' oai-nrf:' + rhel_nrf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
}
}
}
}
post {
always {
script {
copyFrom2ndServer('archives/nrf_podman_image_build.log', 'archives', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
}
success {
sh "echo 'OAI-NRF PODMAN RHEL8 IMAGE BUILD: OK' >> archives/nrf_podman_image_build.log"
}
unsuccessful {
sh "echo 'OAI-NRF PODMAN RHEL8 IMAGE BUILD: KO' >> archives/nrf_podman_image_build.log"
}
}
}
// Running CPPCHECK in parallel to gain time
stage ('Static Code Analysis') {
steps {
script {
gitlabCommitStatus(name: "Static Code Analysis") {
// Running on xenial to have 1.72 version of cppcheck
myShCmd('docker run --name ci-cn-cppcheck -d ubuntu:xenial /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/cppcheck_install.log', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get install --yes cppcheck bzip2" >> archives/cppcheck_install.log', new_host_flag, new_host_user, new_host)
myShCmd('docker run --name ci-cn-cppcheck -d ubuntu:xenial /bin/bash -c "sleep infinity"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/cppcheck_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get install --yes cppcheck bzip2" >> archives/cppcheck_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ./openair-nrf.tar.bz2 ci-cn-cppcheck:/home', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && tar -xjf openair-nrf.tar.bz2"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "rm -f /home/openair-nrf.tar.bz2"', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ./openair-nrf.tar.bz2 ci-cn-cppcheck:/home', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && tar -xjf openair-nrf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "rm -f /home/openair-nrf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && cppcheck --enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list src 2> cppcheck.xml 1> cppcheck_build.log"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && cppcheck --enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list src 2> cppcheck.xml 1> cppcheck_build.log"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
}
post {
always {
script {
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck.xml archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck_build.log archives', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/cppcheck*.*', 'archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck.xml archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck_build.log archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
copyFrom2ndServer('archives/cppcheck*.*', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// no need to keep the cppcheck container
myShCmd('docker rm -f ci-cn-cppcheck', new_host_flag, new_host_user, new_host)
myShCmd('docker rm -f ci-cn-cppcheck', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
success {
......@@ -225,20 +300,20 @@ pipeline {
steps {
script {
gitlabCommitStatus(name: "Code Formatting Checker") {
myShCmd('docker run --name ci-cn-clang-formatter -d ubuntu:bionic /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/clang_format_install.log', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get install --yes git tree bzip2" >> archives/clang_format_install.log', new_host_flag, new_host_user, new_host)
myShCmd('docker run --name ci-cn-clang-formatter -d ubuntu:bionic /bin/bash -c "sleep infinity"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/clang_format_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get install --yes git tree bzip2" >> archives/clang_format_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ./openair-nrf.tar.bz2 ci-cn-clang-formatter:/home', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && tar -xjf openair-nrf.tar.bz2"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "rm -f /home/openair-nrf.tar.bz2"', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ./openair-nrf.tar.bz2 ci-cn-clang-formatter:/home', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && tar -xjf openair-nrf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "rm -f /home/openair-nrf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// We install a dedicated version (installed on our CI server).
myShCmd('docker cp /opt/clang-format/9.0.0/bin/clang-format ci-cn-clang-formatter:/usr/local/bin', new_host_flag, new_host_user, new_host)
myShCmd('docker cp /opt/clang-format/9.0.0/bin/clang-format ci-cn-clang-formatter:/usr/local/bin', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh --src-branch ' + env.gitlabSourceBranch +' --target-branch ' + env.gitlabTargetBranch + '"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh --src-branch ' + env.gitlabSourceBranch +' --target-branch ' + env.gitlabTargetBranch + '"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} else {
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
}
......@@ -246,17 +321,17 @@ pipeline {
post {
always {
script {
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result.txt src', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result.txt src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// May not have been generated
try {
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result_list.txt src', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result_list.txt src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) {
echo "Failed to copy src/oai_rules_result_list.txt! It may not have been generated. That's OK!"
}
copyFrom2ndServer('archives/clang_format*.*', 'archives', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('src/oai_rules*.*', 'src', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/clang_format*.*', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
copyFrom2ndServer('src/oai_rules*.*', 'src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// no need to keep the clang-formatter container
myShCmd('docker rm -f ci-cn-clang-formatter', new_host_flag, new_host_user, new_host)
myShCmd('docker rm -f ci-cn-clang-formatter', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
}
}
......@@ -317,22 +392,35 @@ pipeline {
script {
if ("MERGE".equals(env.gitlabActionType)) {
// Remove CI Base image tag
myShCmd('docker rmi oai-nrf-base:latest', new_host_flag, new_host_user, new_host)
myShCmd('docker rmi oai-nrf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
// Removing temporary / intermediate images
try {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker image rm --force oai-nrf:ci-tmp', new_host_flag, new_host_user, new_host)
myShCmd('docker image rm --force oai-nrf:ci-tmp', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
} catch (Exception e) {
echo "We failed to delete the OAI-NRF temp image"
}
try {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('sudo podman image rm oai-nrf:ci-tmp', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
} catch (Exception e) {
echo "We failed to delete the OAI-NRF temp image"
}
try {
myShCmd('docker image prune --force', new_host_flag, new_host_user, new_host)
myShCmd('docker image prune --force', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) {
echo "We failed to prune all unneeded intermediate images"
}
if (rem_rhel_host_flag) {
try {
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
} catch (Exception e) {
echo "We failed to prune all unneeded intermediate images"
}
}
// Zipping all archived log files
sh "zip -r -qq docker_logs.zip archives"
if (fileExists('docker_logs.zip')) {
......@@ -342,11 +430,21 @@ pipeline {
// Generating the HTML report
if ("MERGE".equals(env.gitlabActionType)) {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${env.gitlabSourceBranch} --git_src_commit=${env.gitlabMergeRequestLastCommit} --git_pull_request=True --git_target_branch=${env.gitlabTargetBranch} --git_target_commit=${GIT_COMMIT}"
if (fileExists('test_results_oai_nrf.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' test_results_oai_nrf.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' test_results_oai_nrf.html"
}
if (fileExists('test_results_oai_cn5g.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g.html"
}
} else {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}"
}
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_nrf.html"
if (fileExists('test_results_oai_nrf.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_nrf.html"
archiveArtifacts artifacts: 'test_results_oai_nrf.html'
}
if (fileExists('test_results_oai_cn5g.html')) {
......@@ -382,8 +480,8 @@ def copyTo2ndServer(filename, flag, user, host) {
sh "scp ${filename} ${user}@${host}:/tmp/CI-CN-NRF"
if ("openair-nrf.tar.bz2".equals(filename)) {
sh "ssh ${user}@${host} 'cd /tmp/CI-CN-NRF && tar -xjf ${filename}'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-NRF/archives'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-NRF/archives/oai-nrf-cfg'"
sh "ssh ${user}@${host} 'rm -Rf /tmp/CI-CN-NRF/${filename}'"
}
}
}
......
......@@ -20,6 +20,7 @@
# */
#---------------------------------------------------------------------
import glob
import os
import re
import sys
......@@ -109,6 +110,15 @@ class HtmlReport():
buildSummary += ' <td><a href="' + self.git_url + '">' + self.git_url + '</a></td>\n'
buildSummary += ' </tr>\n'
if self.git_pull_request:
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n'
buildSummary += ' <td><a href="TEMPLATE_MERGE_REQUEST_LINK">TEMPLATE_MERGE_REQUEST_LINK</a></td>\n'
buildSummary += ' </tr>\n'
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-header"></span> Merge Request Title</td>\n'
buildSummary += ' <td>TEMPLATE_MERGE_REQUEST_TEMPLATE</td>\n'
buildSummary += ' </tr>\n'
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n'
buildSummary += ' <td>' + self.git_src_branch + '</td>\n'
buildSummary += ' </tr>\n'
......@@ -148,23 +158,10 @@ class HtmlReport():
self.file.write(buildSummary)
cwd = os.getcwd()
if os.path.isfile(cwd + '/ds_tester_results_oai_cn5g.html'):
newEpcReport = open(cwd + '/ds_tester_results_oai_cn5g_new.html', 'w')
buildSummaryDone = True
with open(cwd + '/ds_tester_results_oai_cn5g.html', 'r') as originalEpcReport:
for line in originalEpcReport:
result = re.search('DS Tester Summary', line)
if (result is not None) and buildSummaryDone:
newEpcReport.write(buildSummary)
buildSummaryDone = False
newEpcReport.write(line)
originalEpcReport.close()
newEpcReport.close()
os.rename(cwd + '/ds_tester_results_oai_cn5g_new.html', cwd + '/ds_tester_results_oai_cn5g.html')
if os.path.isfile(cwd + '/deploy_results_oai_cn5g.html'):
newEpcReport = open(cwd + '/deploy_results_oai_cn5g_new.html', 'w')
for reportFile in glob.glob('./*results_oai_cn5g.html'):
newEpcReport = open(cwd + '/' + str(reportFile) + '.new', 'w')
buildSummaryDone = True
with open(cwd + '/deploy_results_oai_cn5g.html', 'r') as originalEpcReport:
with open(cwd + '/' + str(reportFile), 'r') as originalEpcReport:
for line in originalEpcReport:
result = re.search('Deployment Summary', line)
if (result is not None) and buildSummaryDone:
......@@ -173,7 +170,7 @@ class HtmlReport():
newEpcReport.write(line)
originalEpcReport.close()
newEpcReport.close()
os.rename(cwd + '/deploy_results_oai_cn5g_new.html', cwd + '/deploy_results_oai_cn5g.html')
os.rename(cwd + '/' + str(reportFile) + '.new', cwd + '/' + str(reportFile))
def generateFooter(self):
self.file.write(' <div class="well well-lg">End of Build Report -- Copyright <span class="glyphicon glyphicon-copyright-mark"></span> 2020 <a href="http://www.openairinterface.org/">OpenAirInterface</a>. All Rights Reserved.</div>\n')
......@@ -366,12 +363,13 @@ class HtmlReport():
self.file.write(' </div>\n')
def buildSummaryHeader(self):
self.file.write(' <h2>Docker Image Build Summary</h2>\n')
self.file.write(' <h2>Docker / Podman Image Build Summary</h2>\n')
self.file.write(' <table class="table-bordered" width = "100%" align = "center" border = "1">\n')
self.file.write(' <tr bgcolor="#33CCFF" >\n')
self.file.write(' <th>Stage Name</th>\n')
self.file.write(' <th>Image Kind</th>\n')
self.file.write(' <th>OAI NRF cNF</th>\n')
self.file.write(' <th>OAI NRF <font color="Gold">Ubuntu18</font> Image</th>\n')
self.file.write(' <th>OAI NRF <font color="Gold">RHEL8</font> Image</th>\n')
self.file.write(' </tr>\n')
def buildSummaryFooter(self):
......@@ -401,13 +399,15 @@ class HtmlReport():
def analyze_docker_build_git_part(self, nfType):
if nfType != 'NRF':
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
logFileName = 'nrf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
section_start_pattern = 'git config --global http'
......@@ -447,13 +447,15 @@ class HtmlReport():
def analyze_install_log(self, nfType):
if nfType != 'NRF':
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
logFileName = 'nrf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
section_start_pattern = 'build_nrf --install-deps --force'
......@@ -470,8 +472,12 @@ class HtmlReport():
pistache_build_status = False
json_build_start = False
json_build_status = False
base_image = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
result = re.search('FROM oai-nrf-base', line)
if result is not None:
base_image = True
result = re.search(section_start_pattern, line)
if result is not None:
section_status = True
......@@ -512,34 +518,49 @@ class HtmlReport():
if result is not None:
json_build_status = True
logfile.close()
if status:
if base_image:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'N/A:\n'
elif status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += ' -- build_nrf --install-deps --force\n'
if package_install:
if base_image:
cell_msg += ' ** Packages Installation: N/A\n'
elif package_install:
cell_msg += ' ** Packages Installation: OK\n'
else:
cell_msg += ' ** Packages Installation: KO\n'
if fmt_build_status:
if base_image:
cell_msg += ' ** fmt Installation: N/A\n'
elif fmt_build_status:
cell_msg += ' ** fmt Installation: OK\n'
else:
cell_msg += ' ** fmt Installation: KO\n'
if folly_build_status:
if base_image:
cell_msg += ' ** folly Installation: N/A\n'
elif folly_build_status:
cell_msg += ' ** folly Installation: OK\n'
else:
cell_msg += ' ** folly Installation: KO\n'
if spdlog_build_status:
if base_image:
cell_msg += ' ** spdlog Installation: N/A\n'
elif spdlog_build_status:
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** spdlog Installation: KO\n'
if pistache_build_status:
if base_image:
cell_msg += ' ** pistache Installation: N/A\n'
elif pistache_build_status:
cell_msg += ' ** pistache Installation: OK\n'
else:
cell_msg += ' ** pistache Installation: KO\n'
if json_build_status:
if base_image:
cell_msg += ' ** Nlohmann Json Installation: N/A\n'
elif json_build_status:
cell_msg += ' ** Nlohmann Json Installation: OK\n'
else:
cell_msg += ' ** Nlohmann Json Installation: KO\n'
......@@ -563,15 +584,16 @@ class HtmlReport():
if nfType != 'NRF':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
if nfType == 'NRF':
logFileName = 'nrf_docker_image_build.log'
if imageKind:
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
if nfType == 'NRF':
......@@ -609,18 +631,18 @@ class HtmlReport():
if nfType != 'NRF':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
if nfType == 'NRF':
logFileName = 'nrf_docker_image_build.log'
if imageKind:
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
nb_errors = 0
nb_warnings = 0
if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'NRF':
section_start_pattern = 'build_nrf --clean --Verbose --build-type Release --jobs'
......@@ -675,13 +697,15 @@ class HtmlReport():
def analyze_copy_log(self, nfType):
if nfType != 'NRF':
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
logFileName = 'nrf_docker_image_build.log'
self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'FROM ubuntu:bionic as oai-nrf$'
section_end_pattern = 'COPY --from=oai-nrf-builder /openair-nrf/scripts/entrypoint.sh entrypoint.sh'
......@@ -719,16 +743,21 @@ class HtmlReport():
def analyze_copy_conf_tool_log(self, nfType):
if nfType != 'NRF':
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
logFileName = 'nrf_docker_image_build.log'
self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'WORKDIR /openair-nrf/etc'
if variant == 'docker':
section_end_pattern = 'Successfully tagged oai-nrf'
else:
section_end_pattern = 'COMMIT oai-nrf:'
section_status = False
status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
......@@ -764,19 +793,24 @@ class HtmlReport():
if nfType != 'NRF':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return
if nfType == 'NRF':
logFileName = 'nrf_docker_image_build.log'
if imageKind:
self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'nrf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'NRF':
if variant == 'docker':
section_start_pattern = 'Successfully tagged oai-nrf'
section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD'
section_end_pattern = 'OAI-NRF DOCKER IMAGE BUILD'
else:
section_start_pattern = 'COMMIT oai-nrf:'
section_end_pattern = 'OAI-NRF PODMAN RHEL8 IMAGE BUILD'
section_status = False
status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
......@@ -794,7 +828,10 @@ class HtmlReport():
else:
result = re.search('oai-nrf *develop', line)
if result is not None:
if variant == 'docker':
result = re.search('ago *([0-9A-Z]+)', line)
else:
result = re.search('ago *([0-9]+ [A-Z]+)', line)
if result is not None:
size = result.group(1)
status = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment