[DO-290] reafactoring Release-activities (!17)
Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/17 Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
committed by
Aleksandr Vodyanov
parent
87ad52f470
commit
8f7b47fe0d
@@ -2,7 +2,3 @@ folder('Release-activity') {
|
|||||||
displayName('Release-activity')
|
displayName('Release-activity')
|
||||||
description('Release activity')
|
description('Release activity')
|
||||||
}
|
}
|
||||||
|
|
||||||
folder('Release-activity/tavro') {
|
|
||||||
description('Release activity for TAVRO team')
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
pipelineJob('Release-activity/tavro/code_freeze') {
|
pipelineJob('Release-activity/Tavro') {
|
||||||
logRotator {
|
logRotator {
|
||||||
numToKeep(10)
|
numToKeep(10)
|
||||||
artifactNumToKeep(10)
|
artifactNumToKeep(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
|
choice {
|
||||||
|
name('BRANCH_TYPE')
|
||||||
|
choices(['Release', 'RC', 'Smoke'])
|
||||||
|
description('Select one of branch types')
|
||||||
|
}
|
||||||
choiceParameter {
|
choiceParameter {
|
||||||
name('SOURCE_BRANCH_NAME')
|
name('SOURCE_BRANCH_NAME')
|
||||||
randomName('')
|
randomName('')
|
||||||
@@ -37,6 +42,12 @@ return branches.sort()
|
|||||||
}
|
}
|
||||||
choiceType('PT_SINGLE_SELECT')
|
choiceType('PT_SINGLE_SELECT')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string {
|
||||||
|
name('VERSION')
|
||||||
|
defaultValue('')
|
||||||
|
description('Release version eg. (1.4 or 1.4-demo)')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
definition {
|
definition {
|
||||||
@@ -47,10 +58,11 @@ return branches.sort()
|
|||||||
url("${JENKINS_GIT_REPOSITORY_URL}/DevOps/jenkins-pipelines.git")
|
url("${JENKINS_GIT_REPOSITORY_URL}/DevOps/jenkins-pipelines.git")
|
||||||
credentials("${JENKINS_GIT_CREDENTIALS_HTTP}")
|
credentials("${JENKINS_GIT_CREDENTIALS_HTTP}")
|
||||||
}
|
}
|
||||||
branch('master')
|
branch('DO-290--reafactoring_release_activities')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scriptPath('pipelines/Release-activity/tavro/code_freeze.groovy')
|
scriptPath('pipelines/Release-activity/tavro.groovy')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
import tech.avroid.api.Gitea
|
import tech.avroid.api.Gitea
|
||||||
|
|
||||||
String rcBranch
|
String branch
|
||||||
String gitToken
|
|
||||||
String apiRepoURL = "${env.JENKINS_GIT_REPOSITORY_URL}/api/v1/repos/TAVRO/TAVRO"
|
String apiRepoURL = "${env.JENKINS_GIT_REPOSITORY_URL}/api/v1/repos/TAVRO/TAVRO"
|
||||||
List parentJobs = ['jobs-dsl']
|
List parentJobs = ['jobs-dsl']
|
||||||
|
|
||||||
@@ -19,7 +18,13 @@ properties([
|
|||||||
numToKeepStr: '10')),
|
numToKeepStr: '10')),
|
||||||
disableConcurrentBuilds(),
|
disableConcurrentBuilds(),
|
||||||
parameters(
|
parameters(
|
||||||
[[$class: 'ChoiceParameter',
|
[
|
||||||
|
choice(
|
||||||
|
name: 'BRANCH_TYPE',
|
||||||
|
choices: ['Release', 'RC', 'Smoke'],
|
||||||
|
description: 'Select one of branch types'
|
||||||
|
),
|
||||||
|
[$class: 'ChoiceParameter',
|
||||||
choiceType: 'PT_SINGLE_SELECT',
|
choiceType: 'PT_SINGLE_SELECT',
|
||||||
filterLength: 1,
|
filterLength: 1,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
@@ -38,17 +43,14 @@ branches.add(branch.name)
|
|||||||
return branches.sort()
|
return branches.sort()
|
||||||
"""]],
|
"""]],
|
||||||
],
|
],
|
||||||
string(name: 'RC_VERSION', defaultValue: '', description: 'Release version eg. (1.4 or 1.4-demo)'),
|
string(name: 'VERSION', defaultValue: '', description: 'Release version eg. (1.4 for release and 1.4.1 for another branches)'),
|
||||||
booleanParam(name: 'TEST_RC_BRANCH',
|
|
||||||
defaultValue: false,
|
|
||||||
description: 'Test RC branch or no. If value is true, branch will be looks as test_rc_1.4')
|
|
||||||
]
|
]
|
||||||
|
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
// Check if job triggered by parent job
|
// Check if job triggered by parent job
|
||||||
boolean isContainsParentJob = parentJobs.any {job -> currentBuild.upstreamBuilds.projectName.contains(job) }
|
Boolean isContainsParentJob = parentJobs.any {job -> currentBuild.upstreamBuilds.projectName.contains(job) }
|
||||||
|
|
||||||
if (isContainsParentJob) {
|
if (isContainsParentJob) {
|
||||||
currentBuild.result = 'SUCCESS'
|
currentBuild.result = 'SUCCESS'
|
||||||
@@ -57,51 +59,46 @@ if (isContainsParentJob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
||||||
yaml: '''
|
yaml: """
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: linux
|
- name: linux
|
||||||
image: harbor.avroid.tech/devops/base-build-image:1.0
|
image: ${env.JENKINS_DOCKER_REGISTRY}/docker-hub-proxy/library/alpine:3.18.5
|
||||||
tty: true
|
tty: true
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 300m
|
cpu: 100m
|
||||||
memory: 256Mi
|
memory: 64Mi
|
||||||
requests:
|
requests:
|
||||||
cpu: 300m
|
cpu: 100m
|
||||||
memory: 256Mi
|
memory: 64Mi
|
||||||
imagePullPolicy: Always
|
"""
|
||||||
imagePullSecrets:
|
|
||||||
- name: harbor-registry-secret
|
|
||||||
'''
|
|
||||||
) {
|
) {
|
||||||
node(POD_LABEL) {
|
node(POD_LABEL) {
|
||||||
stage('Create RC 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+.*/
|
||||||
Gitea tavroRepo = new Gitea(this, apiRepoURL, "${env.JENKINS_GIT_CREDENTIALS_HTTP}")
|
Gitea tavroRepo = new Gitea(this, apiRepoURL, "${env.JENKINS_GIT_CREDENTIALS_HTTP}")
|
||||||
String versionPattern = /^\d+\.\d+.*/
|
branch = params.BRANCH_TYPE.toLowerCase() + params.VERSION
|
||||||
String rcPrefix = 'rc'
|
|
||||||
String rcTest = params.TEST_RC_BRANCH == true ? 'test_' : ''
|
|
||||||
rcBranch = rcTest + rcPrefix + params.RC_VERSION
|
|
||||||
|
|
||||||
if (!params.RC_VERSION.matches(versionPattern)) {
|
if (!params.VERSION.matches(versionPattern)) {
|
||||||
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, rcBranch)
|
Boolean result = tavroRepo.createBranch(params.SOURCE_BRANCH_NAME, branch)
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
println("RC Branch doesn't create, maybe ${rcBranch} already exists")
|
println("Branch doesn't create, maybe ${branch} already exists")
|
||||||
error()
|
error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Run build') {
|
stage('Run build') {
|
||||||
sleep(10)
|
sleep(5)
|
||||||
build(job: "TAVRO Team/TAVRO/${rcBranch}")
|
build(job: "TAVRO Team/TAVRO/${branch}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
@Library('shared-lib') _
|
|
||||||
|
|
||||||
import tech.avroid.api.Gitea
|
|
||||||
|
|
||||||
String apiRepoURL = "${env.JENKINS_GIT_REPOSITORY_URL}/api/v1/repos"
|
|
||||||
List parentJobs = ['jobs-dsl']
|
|
||||||
|
|
||||||
|
|
||||||
withCredentials([usernamePassword(credentialsId: "${JENKINS_GIT_CREDENTIALS_HTTP}",
|
|
||||||
usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_USER_PASSWORD')]) {
|
|
||||||
gitLogin = GITEA_USER
|
|
||||||
gitPass = GITEA_USER_PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
properties([
|
|
||||||
buildDiscarder(logRotator(artifactNumToKeepStr: '10',
|
|
||||||
numToKeepStr: '10')),
|
|
||||||
disableConcurrentBuilds(),
|
|
||||||
parameters(
|
|
||||||
[[$class: 'ChoiceParameter',
|
|
||||||
choiceType: 'PT_SINGLE_SELECT',
|
|
||||||
filterLength: 1,
|
|
||||||
filterable: true,
|
|
||||||
name: 'RC_BRANCH_NAME',
|
|
||||||
script: [$class: 'GroovyScript',
|
|
||||||
script: [sandbox: false, script: """import groovy.json.JsonSlurperClassic
|
|
||||||
def sout = new StringBuffer(), serr = new StringBuffer()
|
|
||||||
def proc = 'curl --connect-timeout 15 -u ${gitLogin}:${gitPass} ${apiRepoURL}/TAVRO/TAVRO/branches'.execute()
|
|
||||||
proc.consumeProcessOutput(sout, serr)
|
|
||||||
proc.waitForOrKill(5000)
|
|
||||||
JSONInfo = new JsonSlurperClassic().parseText(sout.toString())
|
|
||||||
List branches = []
|
|
||||||
JSONInfo.each{ branch ->
|
|
||||||
branches.add(branch.name)
|
|
||||||
}
|
|
||||||
return branches.sort()
|
|
||||||
"""]],
|
|
||||||
]]
|
|
||||||
)])
|
|
||||||
|
|
||||||
String releaseBranch = params.RC_BRANCH_NAME
|
|
||||||
releaseBranch = 'release' + releaseBranch.split('rc').last()
|
|
||||||
|
|
||||||
//// Check if job triggered by parent job
|
|
||||||
//boolean isContainsParentJob = Info.isTriggeredByParent(
|
|
||||||
// script: this,
|
|
||||||
// parentJobs: parentJobs
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//if (isContainsParentJob) {
|
|
||||||
// currentBuild.result = 'SUCCESS'
|
|
||||||
// println("This job was triggered by one or more of following upstream jobs ${parentJobs}, so it will be exited without running the steps.")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
|
||||||
yaml: '''
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Pod
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: linux
|
|
||||||
image: harbor.avroid.tech/devops/base-build-image:1.0
|
|
||||||
tty: true
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 300m
|
|
||||||
memory: 256Mi
|
|
||||||
requests:
|
|
||||||
cpu: 300m
|
|
||||||
memory: 256Mi
|
|
||||||
imagePullPolicy: Always
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: harbor-registry-secret
|
|
||||||
'''
|
|
||||||
) {
|
|
||||||
node(POD_LABEL) {
|
|
||||||
stage('Create Release branch') {
|
|
||||||
currentBuild.description = "Build from ${params.SOURCE_BRANCH_NAME}"
|
|
||||||
Gitea tavroRepo = new Gitea(this, "${apiRepoURL}/TAVRO/TAVRO", "${env.JENKINS_GIT_CREDENTIALS_HTTP}")
|
|
||||||
boolean result = tavroRepo.createBranch(params.RC_BRANCH_NAME, releaseBranch)
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
println("Realease Branch already exists")
|
|
||||||
error()
|
|
||||||
} else {
|
|
||||||
stage('Create SharedLib tag') {
|
|
||||||
Gitea sharedLibRepo = new Gitea(this,
|
|
||||||
"${apiRepoURL}/DevOps/jenkins-shared-lib",
|
|
||||||
"${env.JENKINS_GIT_CREDENTIALS_HTTP}")
|
|
||||||
|
|
||||||
sharedLibRepo.createTag('master', releaseBranch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Run build') {
|
|
||||||
sleep(10)
|
|
||||||
build(job: "TAVRO Team/TAVRO/${releaseBranch}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,6 +40,7 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
|||||||
}
|
}
|
||||||
|
|
||||||
stage('Run job dsl') {
|
stage('Run job dsl') {
|
||||||
|
List launchJobs = [ 'Release-activity/Tavro' ]
|
||||||
jobDsl(
|
jobDsl(
|
||||||
targets: 'jobs-dsl/folders/*.groovy\n' +
|
targets: 'jobs-dsl/folders/*.groovy\n' +
|
||||||
'jobs-dsl/jobs/**/*.groovy\n' +
|
'jobs-dsl/jobs/**/*.groovy\n' +
|
||||||
@@ -50,6 +51,10 @@ podTemplate(workspaceVolume: hostPathWorkspaceVolume(hostPath: "/data"),
|
|||||||
removedViewAction: 'IGNORE',
|
removedViewAction: 'IGNORE',
|
||||||
removedConfigFilesAction: 'IGNORE'
|
removedConfigFilesAction: 'IGNORE'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
launchJobs.each { job ->
|
||||||
|
build(job: job, wait: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
pipelineJob('Release-activity/tavro/feature_freeze') {
|
pipelineJob('Release-activity/Tavro') {
|
||||||
logRotator {
|
logRotator {
|
||||||
numToKeep(10)
|
numToKeep(10)
|
||||||
artifactNumToKeep(10)
|
artifactNumToKeep(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
|
choice {
|
||||||
|
name('BRANCH_TYPE')
|
||||||
|
choices(['Release', 'RC', 'Smoke']),
|
||||||
|
description('Select one of branch types')
|
||||||
choiceParameter {
|
choiceParameter {
|
||||||
name('SOURCE_BRANCH_NAME')
|
name('SOURCE_BRANCH_NAME')
|
||||||
randomName('')
|
randomName('')
|
||||||
@@ -39,16 +43,10 @@ return branches.sort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
string {
|
string {
|
||||||
name('RC_VERSION')
|
name('VERSION')
|
||||||
defaultValue('')
|
defaultValue('')
|
||||||
description('Release version eg. (1.4 or 1.4-demo)')
|
description('Release version eg. (1.4 or 1.4-demo)')
|
||||||
}
|
}
|
||||||
|
|
||||||
booleanParam {
|
|
||||||
name('TEST_RC_BRANCH')
|
|
||||||
defaultValue(false)
|
|
||||||
description('Test RC branch or no. If value is true, branch will be looks as RC_MODC_test_2.0.0')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
definition {
|
definition {
|
||||||
@@ -62,7 +60,7 @@ return branches.sort()
|
|||||||
branch('master')
|
branch('master')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scriptPath('pipelines/Release-activity/tavro/feature_freeze.groovy')
|
scriptPath('pipelines/Release-activity/tavro.groovy')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user