CI: pass pre-computed branch from orchestrator to downstream jobs

Jenkinsfile-GitLab-Container now constructs CI testing branch as
{sourceBranch}-{sourceCommit} and passes it explicitly to all downstream
jobs. Both Jenkinsfile and Jenkinsfile-push-local-repo consume it via
params.branch instead of independently reconstructing the name, ensuring
that the branch pushed by RAN-Local-Repo-Push and the branch checked out
by test jobs are always identical.

Signed-off-by: Jaroslava Fiedlerova <jaroslava.fiedlerova@openairinterface.org>
This commit is contained in:
Jaroslava Fiedlerova
2026-05-22 10:58:44 +02:00
parent cb0e501293
commit 9617344464
6 changed files with 21 additions and 28 deletions

View File

@@ -20,13 +20,11 @@ if (params.LockResources != null && params.LockResources.trim().length() > 0)
// Global Parameters. Normally they should be populated when the master job
// triggers the slave job with parameters
def INTERNAL_REPO = "asterix:/home/git/openairinterface5g.git"
def sourceBranch = params.sourceBranch ?: env.GIT_BRANCH
def targetBranch = params.targetBranch ?: 'develop'
def commitID = params.sourceCommit ?: env.GIT_COMMIT
def testRepository = params.customRepository ?: INTERNAL_REPO
def testBranch = params.customBranch ?: "${sourceBranch}-${commitID}"
def testRepository = params.repository ?: 'git@asterix:/home/git/openairinterface5g.git'
def testBranch = params.branch ?: 'develop'
def mergeWithTarget = params.mergeWithTarget ?: false
def sourceBranch = params.sourceBranch ?: testBranch
def flexricOption = ""
def runWithOC = false
@@ -113,8 +111,7 @@ pipeline {
}
sh """
python3 main.py --mode=InitiateHtml --repository=${testRepository} \
--branch=${testBranch} --commitID=${commitID} \
${mainPythonAllXmlFiles}
--branch=${testBranch} ${mainPythonAllXmlFiles}
"""
if (runWithOC) {
withCredentials([usernamePassword(credentialsId: "${params.OC_Credentials}", usernameVariable: 'OC_Username', passwordVariable: 'OC_Password')]) {

View File

@@ -892,7 +892,9 @@ def triggerSlaveJob (jobName, gitlabStatusName) {
booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)),
booleanParam(name: 'mergeWithTarget', value: "MERGE".equals(env.gitlabActionType)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)),
string(name: 'targetBranch', value: String.valueOf(env.gitlabTargetBranch))
string(name: 'targetBranch', value: String.valueOf(env.gitlabTargetBranch)),
string(name: 'repository', value: String.valueOf(params.ciRepositoryURL))
string(name: 'branch', value: "${env.gitlabSourceBranch}-${env.gitlabMergeRequestLastCommit}")
], propagate: false
def localResult = localStatus.getResult()
echo "${jobName} Slave Job status is ${localResult}"

View File

@@ -77,15 +77,11 @@ pipeline {
}
}
}
stage('Create temporary branch for CI') {
stage('Create testing branch for CI') {
steps {
script {
env.NEW_BRANCH = "${params.sourceBranch}-${params.sourceCommit}"
echo "New branch: ${env.NEW_BRANCH}"
}
sh """
# Checkout source commit
git checkout -B ${env.NEW_BRANCH} ${params.sourceCommit}
git checkout -B ${params.branch} ${params.sourceCommit}
"""
}
}
@@ -93,7 +89,7 @@ pipeline {
when { expression { return params.mergeWithTarget } }
steps {
sh """
echo "Merging target branch ${params.targetBranch} into source branch ${env.NEW_BRANCH}"
echo "Merging target branch ${params.targetBranch} into source branch ${params.branch}"
if ! git merge --ff target/${params.targetBranch} \
-m "Merge ${params.targetBranch} into ${params.sourceBranch} for CI"; then
echo "Merge conflicts detected. Aborting."
@@ -106,9 +102,9 @@ pipeline {
stage('Push merged branch to internal repository') {
steps {
sh """
git remote add internal-repo ${internalRepoURL} || true
echo "Pushing ${env.NEW_BRANCH} to internal repo"
git push --force internal-repo ${env.NEW_BRANCH}
git remote add internal-repo ${params.repository} || true
echo "Pushing ${params.branch} to internal repo"
git push --force internal-repo ${params.branch}
"""
}
}

View File

@@ -71,12 +71,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,CLUSTER):
HTML.branch=matchReg.group(1)
CONTAINERS.branch=matchReg.group(1)
CLUSTER.branch=matchReg.group(1)
elif re.match(r'^\-\-commitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE):
if re.match(r'^\-\-commitID=(.*)$', myArgv, re.IGNORECASE):
matchReg = re.match(r'^\-\-commitID=(.*)$', myArgv, re.IGNORECASE)
else:
matchReg = re.match(r'^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE)
HTML.commitID=matchReg.group(1)
elif re.match(r'^\-\-targetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE):
if re.match(r'^\-\-targetBranch=(.*)$', myArgv, re.IGNORECASE):
matchReg = re.match(r'^\-\-targetBranch=(.*)$', myArgv, re.IGNORECASE)

View File

@@ -35,7 +35,6 @@ class HTMLManagement():
self.repository = ''
self.branch = ''
self.commitID = ''
self.nbTestXMLfiles = 0
self.htmlTabRefs = []
@@ -100,7 +99,13 @@ class HTMLManagement():
self.htmlFile.write(' <td bgcolor = "lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Test Branch </td>\n')
self.htmlFile.write(' <td>' + self.branch + '</td>\n')
self.htmlFile.write(' </tr>\n')
commit_message = subprocess.check_output("git log -n1 --pretty=format:\"%s\" " + self.commitID, shell=True, universal_newlines=True)
commit_id = subprocess.check_output("git log -n1 --pretty=format:\"%H\" ", shell=True, universal_newlines=True)
commit_id = commit_id.strip()
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td bgcolor = "lightcyan" > <span class="glyphicon glyphicon-tag"></span> Commit ID </td>\n')
self.htmlFile.write(' <td>' + commit_id + '</td>\n')
self.htmlFile.write(' </tr>\n')
commit_message = subprocess.check_output("git log -n1 --pretty=format:\"%s\" ", shell=True, universal_newlines=True)
commit_message = commit_message.strip()
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td bgcolor = "lightcyan" > <span class="glyphicon glyphicon-comment"></span> Commit Message </td>\n')

View File

@@ -27,10 +27,9 @@ def GenericHelp(vers):
print(' --local Force local execution: rewrites the test xml script before running to always execute on localhost. Assumes')
print(' images are available locally, will not remove any images and will run inside the current repo directory')
def GitSrvHelp(repository,branch,commit,mergeallow,targetbranch):
def GitSrvHelp(repository,branch,mergeallow,targetbranch):
print(' --repository=[OAI RAN Repository URL] -- ' + repository)
print(' --branch=[OAI RAN Repository Branch] -- ' + branch)
print(' --commitID=[OAI RAN Repository Commit SHA-1] -- ' + commit)
print(' --ranAllowMerge=[Allow Merge Request (with target branch) (true or false)] -- ' + mergeallow)
print(' --targetBranch=[Target Branch in case of a Merge Request] -- ' + targetbranch)