Commit c0d5d277 authored by Raphael Defosseux's avatar Raphael Defosseux

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: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 85d6f4da
...@@ -44,9 +44,12 @@ termStatusArray[termSPGW] = false ...@@ -44,9 +44,12 @@ termStatusArray[termSPGW] = false
termStatusArray[termMME] = false termStatusArray[termMME] = false
termStatusArray[termHSS] = 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_Repository
def eNB_Branch def eNB_Branch
def eNB_CommitID def eNB_CommitID
def eNB_AllowMergeRequestProcess = false
pipeline { pipeline {
agent { agent {
...@@ -118,7 +121,7 @@ pipeline { ...@@ -118,7 +121,7 @@ pipeline {
if (params.eNB_Credentials == null) { if (params.eNB_Credentials == null) {
allParametersPresent = false 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 not present, take the job GIT variables (used for developing)
if (params.eNB_Repository == null) { if (params.eNB_Repository == null) {
eNB_Repository = env.GIT_URL eNB_Repository = env.GIT_URL
...@@ -138,6 +141,9 @@ pipeline { ...@@ -138,6 +141,9 @@ pipeline {
eNB_CommitID = params.eNB_CommitID eNB_CommitID = params.eNB_CommitID
} }
echo "eNB_CommitID : ${eNB_CommitID}" echo "eNB_CommitID : ${eNB_CommitID}"
if (params.eNB_mergeRequest != null) {
eNB_AllowMergeRequestProcess = params.eNB_mergeRequest
}
if (params.EPC_IPAddress == null) { if (params.EPC_IPAddress == null) {
allParametersPresent = false allParametersPresent = false
...@@ -179,7 +185,7 @@ pipeline { ...@@ -179,7 +185,7 @@ pipeline {
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'], [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'],
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_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) { } catch (Exception e) {
currentBuild.result = 'FAILURE' currentBuild.result = 'FAILURE'
......
...@@ -59,6 +59,7 @@ class SSHConnection(): ...@@ -59,6 +59,7 @@ class SSHConnection():
self.eNBIPAddress = '' self.eNBIPAddress = ''
self.eNBRepository = '' self.eNBRepository = ''
self.eNBBranch = '' self.eNBBranch = ''
self.eNB_AllowMerge = False
self.eNBCommitID = '' self.eNBCommitID = ''
self.eNBUserName = '' self.eNBUserName = ''
self.eNBPassword = '' self.eNBPassword = ''
...@@ -165,6 +166,7 @@ class SSHConnection(): ...@@ -165,6 +166,7 @@ class SSHConnection():
self.command('git checkout -f ' + self.eNBCommitID, '\$', 5) 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 # 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 # the potential merge. Note that merge conflicts should already been checked earlier
if (self.eNB_AllowMerge):
if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'): if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'):
self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5)
self.command('source oaienv', '\$', 5) self.command('source oaienv', '\$', 5)
...@@ -998,6 +1000,11 @@ while len(argvs) > 1: ...@@ -998,6 +1000,11 @@ while len(argvs) > 1:
elif re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE): elif re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE) matchReg = re.match('^\-\-eNBRepository=(.+)$', myArgv, re.IGNORECASE)
SSH.eNBRepository = matchReg.group(1) 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): elif re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE) matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE)
SSH.eNBBranch = matchReg.group(1) SSH.eNBBranch = matchReg.group(1)
......
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