Commit 6ae0335b authored by Mohammed Ismail's avatar Mohammed Ismail

[CI] fix on the MR Link and errors

Signed-off-by: default avatarMohammed Ismail <mohammed.ismail@openairinterface.org>
parent e5edd758
......@@ -40,13 +40,16 @@ def rem_rhel_host_user = ""
def rem_rhel8_resource = params.PodmanContainers
// Tags/Branches to use
def amf_tag = parms.amfTag
def amf_tag = params.amfTag
def amf_branch = params.amfBranch
// We are using a base image to speed up CI build.
// This base image is potentially subject to changes over time.
def AMF_BASE_IMAGE_TAG = params.AmfBaseImageTag
// Merge Request Link
def gitlabMergeRequestLink
//-------------------------------------------------------------------------------
// Pipeline start
pipeline {
......@@ -117,8 +120,10 @@ 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-smf/merge_requests/53\" | jq .web_url | sed 's#\"##g'"
echo "========= THIS IS A MERGE REQUEST =========="
echo "MR ID is ${env.gitlabMergeRequestId}"
echo "MR LINK is ${gitlabMergeRequestLink}"
echo "MR TITLE is ${env.gitlabMergeRequestTitle}"
gitCommitAuthorEmailAddr = env.gitlabUserEmail
echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
......@@ -175,7 +180,8 @@ pipeline {
// In case of push to `develop` branch we build from scratch
myShCmd('docker build --no-cache --target oai-amf --tag oai-amf:' + amf_tag + ' --file docker/Dockerfile.ubuntu.18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/amf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
}
if ("MERGE".equals(env.gitlabActionType)) {
else {
//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.
......@@ -219,7 +225,7 @@ pipeline {
} catch (Exception e) {
echo "Maybe a previous build went wrong"
}
else {
} else {
// In case we forgot during a previous run
myShCmd('sudo podman image rm oai-amf:' + amf_tag + ' || true', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
......@@ -422,11 +428,20 @@ 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_amf.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${ghprbPullLink}#g' test_results_oai_amf.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' test_results_oai_amf.html"
}
if (fileExists('test_results_oai_cn5g.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${ghprbPullLink}#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_amf.html"
if (fileExists('test_results_oai_amf.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_amf.html"
archiveArtifacts artifacts: 'test_results_oai_amf.html'
}
if (fileExists('test_results_oai_cn5g.html')) {
......@@ -462,8 +477,8 @@ def copyTo2ndServer(filename, flag, user, host) {
sh "scp ${filename} ${user}@${host}:/tmp/CI-CN-AMF"
if ("openair-amf.tar.bz2".equals(filename)) {
sh "ssh ${user}@${host} 'cd /tmp/CI-CN-AMF && tar -xjf ${filename}'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-AMF/${filename}'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-AMF/archives/oai-amf-cfg'"
sh "ssh ${user}@${host} 'rm -Rf /tmp/CI-CN-AMF/${filename}'"
}
}
}
......
......@@ -109,7 +109,16 @@ 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'
buildSummary += ' <tr>\n'
......@@ -457,7 +466,7 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
section_start_pattern = 'build_amf --install-deps --force'
......@@ -576,7 +585,7 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
if nfType == 'AMF':
......@@ -623,7 +632,7 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
nb_errors = 0
nb_warnings = 0
if os.path.isfile(cwd + '/archives/' + logFileName):
......@@ -688,7 +697,7 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'FROM ubuntu:bionic as oai-amf$'
section_end_pattern = 'WORKDIR /openair-amf/etc'
......@@ -734,10 +743,13 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'WORKDIR /openair-amf/etc'
section_end_pattern = 'Successfully tagged oai-amf'
if variant == 'docker':
section_end_pattern = 'Successfully tagged oai-amf'
else:
section_end_pattern = 'COMMIT oai-amf:'
section_status = False
status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
......@@ -782,11 +794,15 @@ class HtmlReport():
cwd = os.getcwd()
variants = ['docker', 'podman']
for variant in variants:
logFileName = 'spgwu_' + variant + '_image_build.log'
logFileName = 'amf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'AMF':
section_start_pattern = 'Successfully tagged oai-amf'
section_end_pattern = 'OAI-AMF DOCKER IMAGE BUILD'
if variant == 'docker':
section_start_pattern = 'Successfully tagged oai-amf'
section_end_pattern = 'OAI-AMF DOCKER IMAGE BUILD'
else:
section_start_pattern = 'COMMIT oai-amf:'
section_end_pattern = 'OAI-AMF PODMAN RHEL8 IMAGE BUILD'
section_status = False
status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
......@@ -796,15 +812,15 @@ class HtmlReport():
section_status = True
result = re.search(section_end_pattern, line)
if result is not None:
section_status = False
section_status = True
if section_status:
if nfType == 'AMF':
if self.git_pull_request:
result = re.search('oai-amf *ci-tmp', line)
else:
result = re.search('oai-amf *develop', line)
result = re.search('oai-amf *temp', line)
if result is not None:
result = re.search('ago *([0-9A-Z]+)', line)
result = re.search('ago *([0-9A-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