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