-
Notifications
You must be signed in to change notification settings - Fork 45
/
root_jobs.groovy
113 lines (99 loc) · 4.62 KB
/
root_jobs.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// +++++++++++++++++++++++++++++++++++++++++++ root jobs ++++++++++++++++++++++++++++++++++++++++++++++++++++
import org.kie.jenkins.jobdsl.KogitoConstants
import org.kie.jenkins.jobdsl.KogitoJobTemplate
import org.kie.jenkins.jobdsl.Utils
def jobParams = [
job: [
name: '0-prepare-release-branch',
description: 'Prepare env for a release',
],
git: [
repository: Utils.getSeedRepo(this),
author: Utils.getSeedAuthor(this),
credentials: Utils.getSeedAuthorCredsId(this),
branch: Utils.getSeedBranch(this),
],
env: [:],
jenkinsfile: 'dsl/seed/jenkinsfiles/Jenkinsfile.release.prepare',
]
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
RELEASE_PROJECTS.split(',').each { projectName ->
stringParam("${projectName}_VERSION".toUpperCase(), '', "${Utils.getRepoNameCamelCase(projectName)} version to release as Major.minor.micro")
}
if (DEPENDENCY_PROJECTS) {
DEPENDENCY_PROJECTS.split(',').each { projectName ->
stringParam("${projectName}_VERSION".toUpperCase(), '', "${Utils.getRepoNameCamelCase(projectName)} dependency version which this will depend on")
}
}
}
environmentVariables {
env('JENKINS_EMAIL_CREDS_ID', Utils.getJenkinsEmailCredsId(this))
env('SEED_CONFIG_FILE_GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}")
env('SEED_CONFIG_FILE_GIT_AUTHOR_NAME', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}")
env('SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}")
env('SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID}")
env('SEED_CONFIG_FILE_GIT_BRANCH', "${SEED_CONFIG_FILE_GIT_BRANCH}")
env('SEED_CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}")
env('SEED_REPO', Utils.getSeedRepo(this))
env('SEED_AUTHOR', Utils.getSeedAuthor(this))
env('SEED_BRANCH', Utils.getSeedBranch(this))
env('SEED_CREDENTIALS_ID', Utils.getSeedAuthorCredsId(this))
env('SEED_PUSH_CREDENTIALS_ID', Utils.getSeedAuthorPushCredsId(this))
env('AGENT_DOCKER_BUILDER_IMAGE', Utils.getJenkinsAgentDockerImage(this, 'builder'))
env('AGENT_DOCKER_BUILDER_ARGS', Utils.getJenkinsAgentDockerArgs(this, 'builder'))
}
}
def jobParamsRemove = [
job: [
name: '0-remove-branch',
description: 'Remove branches',
],
git: [
repository: Utils.getSeedRepo(this),
author: Utils.getSeedAuthor(this),
credentials: Utils.getSeedAuthorCredsId(this),
branch: Utils.getSeedBranch(this),
],
env: [:],
jenkinsfile: 'dsl/seed/jenkinsfiles/Jenkinsfile.remove.branches',
]
List nonMainBranches = ALL_BRANCHES.split(',').findAll { it != MAIN_BRANCH_NAME }
if (nonMainBranches) {
KogitoJobTemplate.createPipelineJob(this, jobParamsRemove)?.with {
parameters {
choiceParam('BRANCH_TO_REMOVE', nonMainBranches, 'Which release branch to remove ?')
}
environmentVariables {
env('JENKINS_EMAIL_CREDS_ID', Utils.getJenkinsEmailCredsId(this))
env('GIT_REPOSITORY', "${SEED_CONFIG_FILE_GIT_REPOSITORY}")
env('GIT_AUTHOR', "${SEED_CONFIG_FILE_GIT_AUTHOR_NAME}")
env('GIT_AUTHOR_CREDENTIALS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID}")
env('GIT_AUTHOR_PUSH_CREDENTIALS_ID', "${SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID}")
env('GIT_BRANCH_TO_BUILD', "${SEED_CONFIG_FILE_GIT_BRANCH}")
env('CONFIG_FILE_PATH', "${SEED_CONFIG_FILE_PATH}")
env('AGENT_DOCKER_BUILDER_IMAGE', Utils.getJenkinsAgentDockerImage(this, 'builder'))
env('AGENT_DOCKER_BUILDER_ARGS', Utils.getJenkinsAgentDockerArgs(this, 'builder'))
}
}
} else {
println 'No branches to remove ...'
}