[DO-290] add tag for shared libs (!19)

Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/19
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
aleksandr.vodyanov
2024-02-27 15:04:42 +03:00
committed by Aleksandr Vodyanov
parent 358a1e1f51
commit 7c906923e4

View File

@@ -17,8 +17,7 @@ properties([
buildDiscarder(logRotator(artifactNumToKeepStr: '10',
numToKeepStr: '10')),
disableConcurrentBuilds(),
parameters(
[
parameters([
choice(
name: 'BRANCH_TYPE',
choices: ['Release', 'RC', 'Smoke'],
@@ -42,11 +41,9 @@ branches.add(branch.name)
}
return branches.sort()
"""]],
],
string(name: 'VERSION', defaultValue: '', description: 'Release version eg. (1.4 for release and 1.4.1 for another branches)'),
]
)
],
string(name: 'VERSION', defaultValue: '', description: 'Release version eg. (1.4 for release and 1.4.1 for another branches)'),
])
])
// Check if job triggered by parent job
@@ -76,30 +73,39 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
memory: 64Mi
"""
) {
node(POD_LABEL) {
stage('Create branch') {
currentBuild.description = "Build from ${params.SOURCE_BRANCH_NAME}"
node(POD_LABEL) {
stage('Create branch') {
currentBuild.description = "Build from ${params.SOURCE_BRANCH_NAME}"
String versionPattern = (params.BRANCH_TYPE == 'Release') ? /^\d+\.\d+.*/ : /^\d+\.\d+\.\d+.*/
Gitea tavroRepo = new Gitea(this, apiRepoURL, "${env.JENKINS_GIT_CREDENTIALS_HTTP}")
branch = params.BRANCH_TYPE.toLowerCase() + params.VERSION
Gitea tavroRepo = new Gitea(this, apiRepoURL, "${env.JENKINS_GIT_CREDENTIALS_HTTP}")
branch = params.BRANCH_TYPE.toLowerCase() + params.VERSION
println "Branch name: ${branch}"
if (!params.VERSION.matches(versionPattern) || \
if (!params.VERSION.matches(versionPattern) || \
(params.BRANCH_TYPE == 'Release' && params.VERSION.matches(/^\d+\.\d+\.\d+.*/))) {
println('You must specify correct version, see description!')
error()
}
println('You must specify correct version, see description!')
error()
}
Boolean result = tavroRepo.createBranch(params.SOURCE_BRANCH_NAME, branch)
Boolean result = tavroRepo.createBranch(params.SOURCE_BRANCH_NAME, branch)
if (!result) {
println("Branch doesn't create, maybe ${branch} already exists")
error()
}
}
if (!result) {
println("Branch doesn't create, maybe ${branch} already exists")
error()
} else if (params.BRANCH_TYPE == 'Release') {
stage('Create SharedLib tag') {
Gitea sharedLibRepo = new Gitea(this,
"${apiRepoURL}/DevOps/jenkins-shared-lib",
"${env.JENKINS_GIT_CREDENTIALS_HTTP}")
stage('Run build') {
sleep(5)
build(job: "TAVRO Team/TAVRO/${branch}")
}
}
sharedLibRepo.createTag('master', releaseBranch)
}
}
}
stage('Run build') {
sleep(5)
build(job: "TAVRO Team/TAVRO/${branch}")
}
}
}