bugfix: add cleanws in pipelines (!20)

Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/20
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 17:56:26 +03:00
committed by Aleksandr Vodyanov
parent 7c906923e4
commit 8098ef59be
5 changed files with 162 additions and 128 deletions

View File

@@ -74,38 +74,46 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
"""
) {
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
println "Branch name: ${branch}"
if (!params.VERSION.matches(versionPattern) || \
(params.BRANCH_TYPE == 'Release' && params.VERSION.matches(/^\d+\.\d+\.\d+.*/))) {
println('You must specify correct version, see description!')
error()
}
Boolean result = tavroRepo.createBranch(params.SOURCE_BRANCH_NAME, branch)
try {
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
println "Branch name: ${branch}"
if (!params.VERSION.matches(versionPattern) || \
(params.BRANCH_TYPE == 'Release' && params.VERSION.matches(/^\d+\.\d+\.\d+.*/))) {
println('You must specify correct version, see description!')
error()
}
Boolean result = tavroRepo.createBranch(params.SOURCE_BRANCH_NAME, branch)
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}")
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}")
sharedLibRepo.createTag('master', releaseBranch)
sharedLibRepo.createTag('master', releaseBranch)
}
}
}
}
stage('Run build') {
sleep(5)
build(job: "TAVRO Team/TAVRO/${branch}")
stage('Run build') {
sleep(5)
build(job: "TAVRO Team/TAVRO/${branch}")
}
}
catch(err) {
echo 'ERROR: ' + err.getMessage()
currentBuild.result = 'FAILURE'
} finally {
cleanWs()
}
}
}