From 434a0a7d8164e069bd3ffa2b05b29800ea460786 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux <raphael.defosseux@eurecom.fr> Date: Thu, 2 Aug 2018 10:28:45 +0200 Subject: [PATCH] CI: adding merge request allow flag: -- if false no forced merge to develop -- if true and if branch is not develop, then forced merge to develop Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr> --- ci-scripts/Jenkinsfile-tmp-ran | 10 ++++++++-- ci-scripts/main.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-ran b/ci-scripts/Jenkinsfile-tmp-ran index 796271a8d4..83002f82d4 100644 --- a/ci-scripts/Jenkinsfile-tmp-ran +++ b/ci-scripts/Jenkinsfile-tmp-ran @@ -44,9 +44,12 @@ termStatusArray[termSPGW] = false termStatusArray[termMME] = false termStatusArray[termHSS] = false +// Global Parameters. Normally they should be populated when the master job +// triggers the slave job with parameters def eNB_Repository def eNB_Branch def eNB_CommitID +def eNB_AllowMergeRequestProcess = false pipeline { agent { @@ -118,7 +121,7 @@ pipeline { if (params.eNB_Credentials == null) { allParametersPresent = false } - // the following 3 parameters should be pushed by the master trigger + // the following 4 parameters should be pushed by the master trigger // if not present, take the job GIT variables (used for developing) if (params.eNB_Repository == null) { eNB_Repository = env.GIT_URL @@ -138,6 +141,9 @@ pipeline { eNB_CommitID = params.eNB_CommitID } echo "eNB_CommitID : ${eNB_CommitID}" + if (params.eNB_mergeRequest != null) { + eNB_AllowMergeRequestProcess = params.eNB_mergeRequest + } if (params.EPC_IPAddress == null) { allParametersPresent = false @@ -179,7 +185,7 @@ pipeline { [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'], [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'] ]) { - sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${testXMLFile}" + sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNB_AllowMerge=${eNB_AllowMergeRequestProcess} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${testXMLFile}" } } catch (Exception e) { currentBuild.result = 'FAILURE' diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 656b1d11a7..b12786fb68 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -59,6 +59,7 @@ class SSHConnection(): self.eNBIPAddress = '' self.eNBRepository = '' self.eNBBranch = '' + self.eNB_AllowMerge = False self.eNBCommitID = '' self.eNBUserName = '' self.eNBPassword = '' @@ -165,8 +166,9 @@ class SSHConnection(): self.command('git checkout -f ' + self.eNBCommitID, '\$', 5) # if the branch is not develop, then it is a merge request and we need to do # the potential merge. Note that merge conflicts should already been checked earlier - if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'): - self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) + if (self.eNB_AllowMerge): + if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'): + self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) self.command('source oaienv', '\$', 5) self.command('cd cmake_targets', '\$', 5) self.command('mkdir -p log', '\$', 5) @@ -998,6 +1000,11 @@ while len(argvs) > 1: elif re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE) SSH.eNBRepository = matchReg.group(1) + elif re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE) + doMerge = matchReg.group(1) + if ((doMerge == 'true') or (doMerge == 'True')): + SSH.eNB_AllowMerge = True elif re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE) SSH.eNBBranch = matchReg.group(1) -- GitLab