Commit 4c92d678 authored by Raphael Defosseux's avatar Raphael Defosseux

Improvements on Jenkins file:

  - comment to GitLab merge-request does not anymore # as number (misinterpreted as issue number)
  - added local build script w/ generation of HTML result file
Improvements on bash scripts:
  - use of proper option parsing
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent c88284da
Branches unavailable
2024.w06 2024.w05 2024.w04 2024.w03 2024.w02 2024.w01 2023.w51 2023.w50 2023.w49 2023.w48 2023.w47 2023.w45 2023.w43 2023.w42 2023.w41 2023.w40 2023.w39 2023.w38 2023.w37 2023.w36 2023.w34 2023.w33 2023.w32 2023.w31 2023.w30 2023.w29 2023.w28 2023.w27 2023.w26 2023.w25 2023.w24 2023.w23 2023.w22 2023.w21 2023.w20 2023.w19 2023.w18 2023.w18b 2023.w16 2023.w15 2023.w14 2023.w13 2023.w12 2023.w11 2023.w11b 2023.w10 2023.w10b 2023.w09 2023.w08 2023.w08b 2023.w07 2023.w06 2023.w05 2023.w03 2023.w02 2022.42 2022.41 2022.w51 2022.w50 2022.w49 2022.w48 2022.w47 2022.w46 2022.w45 2022.w43 2022.w42 2022.w42b 2022.w41 2022.w40 2022.w39 2022.w38 2022.w37 2022.w37b 2022.w36 2022.w35 2022.w33 2022.w32 2022.w31 2022.w31b 2022.w30 2022.w29 2022.w26 2022.w25 2022.w24 2022.w24b 2022.w23 2022.w22 2022.w21 2022.w20 2022.w19 2022.w18 2022.w17 2022.w15 2022.w15b 2022.w14a 2022.w13 2022.w13b 2022.w13a 2022.w12 2022.w10 2022.w09 2022.w09b 2022.w08 2022.w08b 2022.w07 2022.w07b 2022.w06 2022.w06a 2022.w05 2022.w05b 2022.w03_hotfix 2022.w03_b 2022.w02 2022.w01 2021.wk46 2021.wk14_a 2021.wk13_d 2021.wk13_c 2021.w51_c 2021.w51_a 2021.w50_a 2021.w49_b 2021.w49_a 2021.w48 2021.w47 2021.w46 2021.w46-powder 2021.w45 2021.w45_b 2021.w44 2021.w43 2021.w42 2021.w37 2021.w36 2021.w35 2021.w34 2021.w33 2021.w32 2021.w31 2021.w30 2021.w29 2021.w28 2021.w27 2021.w26 2021.w25 2021.w24 2021.w23 2021.w22 2021.w20 2021.w19 2021.w18_b 2021.w18_a 2021.w17_b 2021.w16 2021.w15 2021.w14 2021.w13_a 2021.w12 2021.w11 2021.w10 2021.w09 2021.w08 2021.w06 2021.w05 2021.w04 2021.w02 2020.w51_2 2020.w51 2020.w50 2020.w49 2020.w48_2 2020.w48 2020.w47 2020.w46_2 2020.w46 2020.w45_2 2020.w45 2020.w44 2020.w42_2 2020.w42 2020.w41 2020.w39 2020.w38 2020.w37 2020.w36 2020.w34 2020.w33 2020.w31 2020.w30 2020.w29 2020.w28 2020.w26 2020.w25 2020.w24 2020.w23 2020.w22 2020.w19 2020.w17 2020.w16 2020.w15 2020.w11 2020.w09 2020.w06 2020.w05 2020.w04 2020.w03 2019.w51 2019.w44 2019.w41 2019.w36 2019.w30 2019.w28 2019.w27 2019.w25 2019.w23 2019.w21 2019.w17 2019.w15 2019.w13 2019.w11 2019.w10 2019.w09 2019.w08 2019.w07 2019.w06 2019.w04 2019.w03 2018.w51 2018.w48 2018.w47 2018.w46 2018.w44 2018.w41 2018.w40 2018.w39 2018.w36 2018.w33 2018.w31 2018.w29 2018.w25 v2.1.0 v2.0.0 v1.2.2 v1.2.1 v1.2.0 v1.1.1 v1.1.0 v1.0.3 v1.0.2 v1.0.1 v1.0.0 setparam osa-etsi-ws-ue osa-etsi-ws-try2 osa-etsi-ws-try1 osa-etsi-ws-gNB nr-ip-over-lte nr-ip-over-lte-v.1.5 nr-ip-over-lte-v.1.4 nr-ip-over-lte-v.1.3 nr-ip-over-lte-v.1.2 nr-ip-over-lte-v.1.1 nr-ip-over-lte-v.1.0 flexran-eol develop-nr-pdcch develop-nr-2020w03 develop-nr-2020w02 develop-nr-2019w51 develop-nr-2019w50 develop-nr-2019w48 develop-nr-2019w47 develop-nr-2019w45 develop-nr-2019w43 develop-nr-2019w42 develop-nr-2019w40 develop-nr-2019w28 develop-nr-2019w23 benetel_phase_rotation benetel_gnb_rel_2.0 benetel_gnb_rel_1.0 benetel_enb_rel_2.0 benetel_enb_rel_1.0
No related merge requests found
...@@ -9,34 +9,66 @@ pipeline { ...@@ -9,34 +9,66 @@ pipeline {
timestamps() timestamps()
gitLabConnection('OAI GitLab') gitLabConnection('OAI GitLab')
//gitlabBuilds(builds: ["Build", "Test"]) //gitlabBuilds(builds: ["Build", "Test"])
gitlabBuilds(builds: ["Local Build"])
} }
stages { stages {
stage ("Verify Parameters") { stage ("Verify Guidelines") {
steps { steps {
echo 'Verify Parameters'
echo "Git URL is ${GIT_URL}" echo "Git URL is ${GIT_URL}"
echo "GitLab Act is ${env.gitlabActionType}" echo "GitLab Act is ${env.gitlabActionType}"
script { script {
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
// GitLab-Jenkins pugin integration is lacking to perform the merge by itself // GitLab-Jenkins plugin integration is lacking to perform the merge by itself
// Doing it manually --> it may have merge conflicts // Doing it manually --> it may have merge conflicts
sh "./ci-scripts/doGitLabMerge.sh ${env.gitlabSourceBranch} ${env.gitlabMergeRequestLastCommit} ${env.gitlabTargetBranch} ${GIT_COMMIT}" sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
sh "./ci-scripts/checkCodingFormattingRules.sh ${env.gitlabSourceBranch} ${env.gitlabTargetBranch}"
// Running astyle options on the list of modified files by the merge request
// For the moment, there is no fail criteria. Just a notification of number of files that do not follow
sh "./ci-scripts/checkCodingFormattingRules.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}"
def res=readFile('./oai_rules_result.txt').trim(); def res=readFile('./oai_rules_result.txt').trim();
if ("0".equals(res)) { if ("0".equals(res)) {
addGitLabMRComment comment: "All Changed files in Merge Request follow OAI Formatting Rules" def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): All Changed files in Merge Request follow OAI Formatting Rules"
addGitLabMRComment comment: message
} else { } else {
addGitLabMRComment comment: "Some Changed files in Merge Request DO NOT follow OAI Formatting Rules" def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some Changed files in Merge Request DO NOT follow OAI Formatting Rules"
addGitLabMRComment comment: message
} }
} else { } else {
echo "Git Branch is ${GIT_BRANCH}" echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}" echo "Git Commit is ${GIT_COMMIT}"
// Running astyle options on all C/H files in the repository
// For the moment, there is no fail criteria. Just a notification of number of files that do not follow
sh "./ci-scripts/checkCodingFormattingRules.sh" sh "./ci-scripts/checkCodingFormattingRules.sh"
} }
} }
} }
} }
stage ("Local Build") {
steps {
gitlabCommitStatus(name: "Local Build") {
sh "./ci-scripts/buildLocally.sh $WORKSPACE"
}
}
post {
always {
script {
if(fileExists('archives/local_build_logs.zip')) {
archiveArtifacts artifacts: 'archives/local_build_logs.zip'
}
if ("MERGE".equals(env.gitlabActionType)) {
sh "./ci-scripts/reportBuildLocally.sh --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
} else {
sh "./ci-scripts/reportBuildLocally.sh --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger push --branch ${GIT_BRANCH} --commit ${GIT_COMMIT}"
}
if(fileExists('build_results.html')) {
archiveArtifacts artifacts: 'build_results.html'
}
}
}
}
}
} }
post { post {
always { always {
...@@ -46,11 +78,11 @@ pipeline { ...@@ -46,11 +78,11 @@ pipeline {
} }
success { success {
script { script {
def message = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ")" def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event" echo "This is a MERGE event"
addGitLabMRComment comment: message addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'good', message: message2 slackSend channel: 'ci-enb', color: 'good', message: message2
} else { } else {
slackSend channel: 'ci-enb', color: 'good', message: message slackSend channel: 'ci-enb', color: 'good', message: message
...@@ -59,11 +91,11 @@ pipeline { ...@@ -59,11 +91,11 @@ pipeline {
} }
failure { failure {
script { script {
def message = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ")" def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event" echo "This is a MERGE event"
addGitLabMRComment comment: message addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'danger', message: message2 slackSend channel: 'ci-enb', color: 'danger', message: message2
} else { } else {
slackSend channel: 'ci-enb', color: 'danger', message: message slackSend channel: 'ci-enb', color: 'danger', message: message
......
#!/bin/bash
function usage {
echo "OAI Local Build Check script"
echo " Original Author: Raphael Defosseux"
echo ""
echo "Usage:"
echo "------"
echo " buildLocally.sh [OPTIONS]"
echo ""
echo "Options:"
echo "--------"
echo " --workspace #### OR -ws ####"
echo " Specify the workspace"
echo ""
echo " --help OR -h"
echo " Print this help message."
echo ""
}
if [ $# -ne 2 ] && [ $# -ne 1 ]
then
echo "Syntax Error: not the correct number of arguments"
echo ""
usage
exit 1
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift
usage
exit 0
;;
-ws|--workspace)
JENKINS_WKSP="$2"
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
done
cd $JENKINS_WKSP
############################################################
# Creating a tmp folder to store results and artifacts
############################################################
if [ ! -d $JENKINS_WKSP/archives ]
then
mkdir $JENKINS_WKSP/archives
fi
source oaienv
cd $JENKINS_WKSP/cmake_targets
############################################################
# Building eNb with USRP option
############################################################
ARCHIVES_LOC=$JENKINS_WKSP/archives/enb_usrp
if [ ! -d $ARCHIVES_LOC ]
then
mkdir $ARCHIVES_LOC
fi
./build_oai --eNB -w USRP -c
# Generated log files:
if [ -f $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt $ARCHIVES_LOC
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt $ARCHIVES_LOC
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt $ARCHIVES_LOC
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt $ARCHIVES_LOC
fi
############################################################
# Building basic simulator
############################################################
ARCHIVES_LOC=$JENKINS_WKSP/archives/basic_sim
if [ ! -d $ARCHIVES_LOC ]
then
mkdir $ARCHIVES_LOC
fi
cd $JENKINS_WKSP/cmake_targets
./build_oai --basic-simulator -c
# Generated log files:
if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt $ARCHIVES_LOC
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt $ARCHIVES_LOC
fi
if [ -f $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt ]
then
cp $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt $ARCHIVES_LOC
fi
############################################################
# Creating a zip for Jenkins archiving
############################################################
cd $JENKINS_WKSP/archives/
zip -r local_build_logs.zip basic_sim enb_usrp
#!/bin/bash #!/bin/bash
function usage {
echo "OAI Coding / Formatting Guideline Check script"
echo " Original Author: Raphael Defosseux"
echo ""
echo " Requirement: astyle shall be installed"
echo ""
echo " By default (no options) the complete repository will be checked"
echo " In case of merge request, provided source and target branch,"
echo " the script will check only the modified files"
echo ""
echo "Usage:"
echo "------"
echo " checkCodingFormattingRules.sh [OPTIONS]"
echo ""
echo "Options:"
echo "--------"
echo " --src-branch #### OR -sb ####"
echo " Specify the source branch of the merge request."
echo ""
echo " --target-branch #### OR -tb ####"
echo " Specify the target branch of the merge request (usually develop)."
echo ""
echo " --help OR -h"
echo " Print this help message."
echo ""
}
if [ $# -ne 4 ] && [ $# -ne 1 ] && [ $# -ne 0 ]
then
echo "Syntax Error: not the correct number of arguments"
echo ""
usage
exit 1
fi
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
echo " ---- Checking the whole repository ----"
echo ""
NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted ` NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted `
echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT" echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT"
echo $NB_FILES_TO_FORMAT > ./oai_rules_result.txt
exit 0 exit 0
fi fi
if [ $# -eq 2 ] checker=0
then while [[ $# -gt 0 ]]
# Merge request scenario do
key="$1"
SOURCE_BRANCH=$1 case $key in
echo "Source Branch is : $SOURCE_BRANCH" -h|--help)
shift
usage
exit 0
;;
-sb|--src-branch)
SOURCE_BRANCH="$2"
let "checker|=0x1"
shift
shift
;;
-tb|--target-branch)
TARGET_BRANCH="$2"
let "checker|=0x2"
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
TARGET_BRANCH=$2 done
if [ $checker -ne 3 ]
then
echo "Source Branch is : $SOURCE_BRANCH"
echo "Target Branch is : $TARGET_BRANCH" echo "Target Branch is : $TARGET_BRANCH"
echo ""
echo "Syntax Error: missing option"
echo ""
usage
exit 1
fi
MERGE_COMMMIT=`git log -n1 | grep commit | sed -e "s@commit @@"` # Merge request scenario
echo "Merged Commit is : $MERGE_COMMMIT"
TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH`
echo "Target Init is : $TARGET_INIT_COMMIT"
# Retrieve the list of modified files since the latest develop commit MERGE_COMMMIT=`git log -n1 | grep commit | sed -e "s@commit @@"`
MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq` TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH`
NB_TO_FORMAT=0
for FULLFILE in $MODIFIED_FILES echo " ---- Checking the modified files by the merge request ----"
do echo ""
echo "Source Branch is : $SOURCE_BRANCH"
echo "Target Branch is : $TARGET_BRANCH"
echo "Merged Commit is : $MERGE_COMMMIT"
echo "Target Init is : $TARGET_INIT_COMMIT"
# Retrieve the list of modified files since the latest develop commit
MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq`
NB_TO_FORMAT=0
for FULLFILE in $MODIFIED_FILES
do
echo $FULLFILE echo $FULLFILE
filename=$(basename -- "$FULLFILE") filename=$(basename -- "$FULLFILE")
EXT="${filename##*.}" EXT="${filename##*.}"
...@@ -35,17 +114,8 @@ then ...@@ -35,17 +114,8 @@ then
TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted ` TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted `
NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT)) NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT))
fi fi
done done
echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT" echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT"
echo $NB_TO_FORMAT > ./oai_rules_result.txt echo $NB_TO_FORMAT > ./oai_rules_result.txt
exit 0 exit 0
fi
if [ $# -ne 0 ] || [ $# -ne 2 ]
then
echo "Syntax error: $0 without any option will check all files in repository"
echo " or: $0 source-branch target-branch"
echo " will only check files that are pushed for a merge-request"
exit 1
fi
#!/bin/bash #!/bin/bash
if [ $# -ne 4 ] function usage {
echo "OAI GitLab merge request applying script"
echo " Original Author: Raphael Defosseux"
echo ""
echo "Usage:"
echo "------"
echo ""
echo " doGitLabMerge.sh [OPTIONS] [MANDATORY_OPTIONS]"
echo ""
echo "Mandatory Options:"
echo "------------------"
echo ""
echo " --src-branch #### OR -sb ####"
echo " Specify the source branch of the merge request."
echo ""
echo " --src-commit #### OR -sc ####"
echo " Specify the source commit ID (SHA-1) of the merge request."
echo ""
echo " --target-branch #### OR -tb ####"
echo " Specify the target branch of the merge request (usually develop)."
echo ""
echo " --target-commit #### OR -tc ####"
echo " Specify the target commit ID (SHA-1) of the merge request."
echo ""
echo "Options:"
echo "--------"
echo " --help OR -h"
echo " Print this help message."
echo ""
}
if [ $# -ne 8 ] && [ $# -ne 1 ]
then then
echo "Syntax Error: $0 src-branch src-commit-id dest-branch dest-commit-id" echo "Syntax Error: not the correct number of arguments"
echo ""
usage
exit 1 exit 1
fi fi
SOURCE_BRANCH=$1 checker=0
echo "Source Branch is : $SOURCE_BRANCH" while [[ $# -gt 0 ]]
do
key="$1"
SOURCE_COMMIT_ID=$2 case $key in
echo "Source Commit ID is : $SOURCE_COMMIT_ID" -h|--help)
shift
usage
exit 0
;;
-sb|--src-branch)
SOURCE_BRANCH="$2"
let "checker|=0x1"
shift
shift
;;
-sc|--src-commit)
SOURCE_COMMIT_ID="$2"
let "checker|=0x2"
shift
shift
;;
-tb|--target-branch)
TARGET_BRANCH="$2"
let "checker|=0x4"
shift
shift
;;
-tc|--target-commit)
TARGET_COMMIT_ID="$2"
let "checker|=0x8"
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
TARGET_BRANCH=$3 done
echo "Target Branch is : $TARGET_BRANCH"
TARGET_COMMIT_ID=$4 echo "Source Branch is : $SOURCE_BRANCH"
echo "Source Commit ID is : $SOURCE_COMMIT_ID"
echo "Target Branch is : $TARGET_BRANCH"
echo "Target Commit ID is : $TARGET_COMMIT_ID" echo "Target Commit ID is : $TARGET_COMMIT_ID"
if [ $checker -ne 15 ]
then
echo ""
echo "Syntax Error: missing option"
echo ""
usage
exit 1
fi
git config user.email "jenkins@openairinterface.org" git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins" git config user.name "OAI Jenkins"
...@@ -25,3 +104,6 @@ git checkout -f $SOURCE_COMMIT_ID ...@@ -25,3 +104,6 @@ git checkout -f $SOURCE_COMMIT_ID
git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI" git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI"
exit 0
This diff is collapsed.
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