Commit d2b9f0f4 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: added support for MR target branch other than 'develop'

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 2a487964
...@@ -53,6 +53,7 @@ def eNB_Repository ...@@ -53,6 +53,7 @@ def eNB_Repository
def eNB_Branch def eNB_Branch
def eNB_CommitID def eNB_CommitID
def eNB_AllowMergeRequestProcess = false def eNB_AllowMergeRequestProcess = false
def eNB_TargetBranch
pipeline { pipeline {
agent { agent {
...@@ -150,6 +151,14 @@ pipeline { ...@@ -150,6 +151,14 @@ pipeline {
echo "eNB_CommitID : ${eNB_CommitID}" echo "eNB_CommitID : ${eNB_CommitID}"
if (params.eNB_mergeRequest != null) { if (params.eNB_mergeRequest != null) {
eNB_AllowMergeRequestProcess = params.eNB_mergeRequest eNB_AllowMergeRequestProcess = params.eNB_mergeRequest
if (eNB_AllowMergeRequestProcess) {
if (params.eNB_TargetBranch != null) {
eNB_TargetBranch = params.eNB_TargetBranch
} else {
eNB_TargetBranch = 'develop'
}
echo "eNB_TargetBranch : ${eNB_TargetBranch}"
}
} }
if (params.EPC_IPAddress == null) { if (params.EPC_IPAddress == null) {
...@@ -192,7 +201,7 @@ pipeline { ...@@ -192,7 +201,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} --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}" sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNB_AllowMerge=${eNB_AllowMergeRequestProcess} --eNBTargetBranch=${eNB_TargetBranch} --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'
......
...@@ -78,6 +78,7 @@ class SSHConnection(): ...@@ -78,6 +78,7 @@ class SSHConnection():
self.eNBBranch = '' self.eNBBranch = ''
self.eNB_AllowMerge = False self.eNB_AllowMerge = False
self.eNBCommitID = '' self.eNBCommitID = ''
self.eNBTargetBranch = ''
self.eNBUserName = '' self.eNBUserName = ''
self.eNBPassword = '' self.eNBPassword = ''
self.eNBSourceCodePath = '' self.eNBSourceCodePath = ''
...@@ -264,8 +265,12 @@ class SSHConnection(): ...@@ -264,8 +265,12 @@ class SSHConnection():
# 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.eNB_AllowMerge):
if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'): if self.eNBTargetBranch == '':
self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) if (self.eNBBranch != 'develop') and (self.eNBBranch != 'origin/develop'):
self.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5)
else:
logging.debug('Merging with the target branch: ' + self.eNBTargetBranch)
self.command('git merge --ff origin/' + self.eNBTargetBranch + ' -m "Temporary merge for CI"', '\$', 5)
self.command('source oaienv', '\$', 5) self.command('source oaienv', '\$', 5)
self.command('cd cmake_targets', '\$', 5) self.command('cd cmake_targets', '\$', 5)
self.command('mkdir -p log', '\$', 5) self.command('mkdir -p log', '\$', 5)
...@@ -1759,7 +1764,10 @@ class SSHConnection(): ...@@ -1759,7 +1764,10 @@ class SSHConnection():
if (SSH.eNB_AllowMerge): if (SSH.eNB_AllowMerge):
self.htmlFile.write(' <tr>\n') self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td bgcolor = "lightcyan" >Target Branch</td>\n') self.htmlFile.write(' <td bgcolor = "lightcyan" >Target Branch</td>\n')
self.htmlFile.write(' <td>develop</td>\n') if (self.eNBTargetBranch == ''):
self.htmlFile.write(' <td>develop</td>\n')
else:
self.htmlFile.write(' <td>' + self.eNBTargetBranch + '</td>\n')
self.htmlFile.write(' </tr>\n') self.htmlFile.write(' </tr>\n')
self.htmlFile.write(' </table>\n') self.htmlFile.write(' </table>\n')
...@@ -1906,6 +1914,8 @@ def Usage(): ...@@ -1906,6 +1914,8 @@ def Usage():
print(' --eNBRepository=[eNB\'s Repository URL]') print(' --eNBRepository=[eNB\'s Repository URL]')
print(' --eNBBranch=[eNB\'s Branch Name]') print(' --eNBBranch=[eNB\'s Branch Name]')
print(' --eNBCommitID=[eNB\'s Commit Number]') print(' --eNBCommitID=[eNB\'s Commit Number]')
print(' --eNB_AllowMerge=[eNB\'s Allow Merge Request (with target branch)]')
print(' --eNBTargetBranch=[eNB\'s Target Branch in case of a Merge Request]')
print(' --eNBUserName=[eNB\'s Login User Name]') print(' --eNBUserName=[eNB\'s Login User Name]')
print(' --eNBPassword=[eNB\'s Login Password]') print(' --eNBPassword=[eNB\'s Login Password]')
print(' --eNBSourceCodePath=[eNB\'s Source Code Path]') print(' --eNBSourceCodePath=[eNB\'s Source Code Path]')
...@@ -2002,6 +2012,9 @@ while len(argvs) > 1: ...@@ -2002,6 +2012,9 @@ while len(argvs) > 1:
elif re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE): elif re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE) matchReg = re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE)
SSH.eNBCommitID = matchReg.group(1) SSH.eNBCommitID = matchReg.group(1)
elif re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE)
SSH.eNBTargetBranch = matchReg.group(1)
elif re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE): elif re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE) matchReg = re.match('^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE)
SSH.eNBUserName = matchReg.group(1) SSH.eNBUserName = 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