/
jobs.groovy
269 lines (222 loc) · 12 KB
/
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
import org.kie.jenkins.jobdsl.KogitoJobTemplate
import org.kie.jenkins.jobdsl.model.JobType
import org.kie.jenkins.jobdsl.utils.JobParamsUtils
import org.kie.jenkins.jobdsl.utils.VersionUtils
import org.kie.jenkins.jobdsl.KogitoJobUtils
import org.kie.jenkins.jobdsl.Utils
JENKINSFILE_PATH = '.ci/jenkins'
boolean isMainStream() {
return Utils.getStream(this) == 'main'
}
// Tools
setupUpdateJenkinsDependenciesJob()
if (isMainStream()) {
setupCreateIssueToolsJob()
setupCleanOldNamespacesToolsJob()
setupCleanOldNightlyImagesToolsJob()
KogitoJobUtils.createQuarkusPlatformUpdateToolsJob(this, 'kogito')
if (Utils.isMainBranch(this)) {
setupBuildOperatorNode()
}
KogitoJobUtils.createMainQuarkusUpdateToolsJob(this,
[ 'kogito-runtimes', 'kogito-examples', 'kogito-docs', 'kogito-images' ],
[ 'rgdoliveira', 'mareknovotny' ]
)
}
// Setup branch branch
createSetupBranchJob()
if (isMainStream()) {
createSetupBranchCloudJob()
}
// Nightly
setupNightlyJob()
setupQuarkusPlatformJob(JobType.NIGHTLY)
if (isMainStream()) {
setupNightlyCloudJob()
}
KogitoJobUtils.createEnvironmentIntegrationBranchNightlyJob(this, 'quarkus-main')
KogitoJobUtils.createEnvironmentIntegrationBranchNightlyJob(this, 'quarkus-branch')
// Release
setupReleaseArtifactsJob()
setupReleaseCloudJob()
/////////////////////////////////////////////////////////////////
// Methods
/////////////////////////////////////////////////////////////////
void setupCleanOldNamespacesToolsJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-clean-old-namespaces', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.tools.clean-old-namespaces")
jobParams.triggers = [ cron : '@midnight' ]
KogitoJobTemplate.createPipelineJob(this, jobParams)
}
void setupCleanOldNightlyImagesToolsJob() {
jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-clean-old-nightly-images', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.tools.clean-nightly-images")
jobParams.triggers = [ cron : 'H 8 * * *' ]
KogitoJobTemplate.createPipelineJob(this, jobParams)
}
void setupCreateIssueToolsJob() {
jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-create-issue', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.tools.create-issue")
jobParams.env.putAll([
GITHUB_CLI_PATH: '/opt/tools/gh-cli/bin/gh',
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('AUTHOR', '', 'Git author')
stringParam('REPOSITORY', '', 'Git repository')
stringParam('BRANCH', 'main', 'Git branch')
stringParam('ISSUE_TITLE', '', 'Title of the issue')
textParam('ISSUE_BODY', '', 'Body of the issue')
}
}
}
void setupUpdateJenkinsDependenciesJob() {
jobParams = JobParamsUtils.getBasicJobParams(this, 'jenkins-update-framework-deps', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.tools.update-jenkins-dependencies", 'Nightly check of Jenkins dependencies from framework against current version of Jenkins')
jobParams.triggers = [cron : '@midnight']
jobParams.env.putAll([
REPO_NAME: 'kogito-pipelines',
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
BUILD_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)
}
void createSetupBranchJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-setup-branch', JobType.SETUP_BRANCH, "${JENKINSFILE_PATH}/Jenkinsfile.setup-branch", 'Kogito Setup Branch for Artifacts')
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('KOGITO_VERSION', '', 'Kogito version')
stringParam('DROOLS_VERSION', '', 'Drools version')
booleanParam('DEPLOY', true, 'Should be deployed after setup ?')
booleanParam('SKIP_CLOUD_SETUP_BRANCH', !isMainStream(), 'Skip Cloud setup branch call')
}
}
}
void createSetupBranchCloudJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-setup-branch-cloud', JobType.SETUP_BRANCH, "${JENKINSFILE_PATH}/Jenkinsfile.setup-branch.cloud", 'Kogito Setup Branch for Cloud')
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('KOGITO_VERSION', '', 'Kogito version')
booleanParam('DEPLOY', true, 'Should be deployed after setup ?')
}
}
}
void setupNightlyJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-kogito-nightly', JobType.NIGHTLY, "${JENKINSFILE_PATH}/Jenkinsfile.nightly", 'Kogito Nightly')
jobParams.triggers = [cron : isMainStream () ? '@midnight' : 'H 4 * * *']
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
booleanParam('DEPLOY', false, 'Should be deployed after setup ?')
booleanParam('SKIP_TESTS', false, 'Skip all tests')
booleanParam('SKIP_CLOUD_NIGHTLY', !isMainStream(), 'Skip cloud nightly execution')
}
}
}
void setupNightlyCloudJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-kogito-nightly-cloud', JobType.NIGHTLY, "${JENKINSFILE_PATH}/Jenkinsfile.nightly.cloud", 'Kogito Nightly')
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
IMAGE_REGISTRY_CREDENTIALS: "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_NIGHTLY}",
IMAGE_REGISTRY: "${CLOUD_IMAGE_REGISTRY}",
IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}",
BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}",
MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}",
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
booleanParam('SKIP_TESTS', false, 'Skip all tests')
booleanParam('SKIP_IMAGES', false, 'To skip Images Deployment')
booleanParam('SKIP_EXAMPLES_IMAGES', false, 'To skip Examples Images Deployment')
booleanParam('SKIP_OPERATOR', false, 'To skip Operator Deployment')
booleanParam('USE_TEMP_OPENSHIFT_REGISTRY', false, 'If enabled, use Openshift registry to push temporary images')
}
}
}
void setupQuarkusPlatformJob(JobType jobType) {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'quarkus-platform.deploy', jobType, "${JENKINSFILE_PATH}/Jenkinsfile.nightly.quarkus-platform", 'Kogito Quarkus platform job')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
QUARKUS_PLATFORM_NEXUS_URL: Utils.getMavenQuarkusPlatformRepositoryUrl(this),
QUARKUS_PLATFORM_NEXUS_CREDS: Utils.getMavenQuarkusPlatformRepositoryCredentialsId(this),
])
KogitoJobTemplate.createPipelineJob(this, jobParams)
}
void setupReleaseArtifactsJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-kogito-release', JobType.RELEASE, "${JENKINSFILE_PATH}/Jenkinsfile.release", 'Kogito Artifacts Release')
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
DEFAULT_STAGING_REPOSITORY: "${MAVEN_NEXUS_STAGING_PROFILE_URL}",
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued')
stringParam('KOGITO_VERSION', '', 'Kogito version to release as Major.minor.micro')
stringParam('DROOLS_VERSION', '', 'Drools version to set for the release')
booleanParam('DEPLOY_AS_LATEST', false, 'Given project version is considered the latest version')
booleanParam('SKIP_TESTS', false, 'Skip all tests')
booleanParam('SKIP_CLOUD_RELEASE', !isMainStream(), 'To skip Cloud release. To use whenever you have specific parameters to set for the Cloud release')
}
}
}
void setupReleaseCloudJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, '0-kogito-release-cloud', JobType.RELEASE, "${JENKINSFILE_PATH}/Jenkinsfile.release.cloud", 'Kogito Cloud Release')
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
GIT_BRANCH_NAME: "${GIT_BRANCH}",
GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
IMAGE_REGISTRY_CREDENTIALS: "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_RELEASE}",
IMAGE_REGISTRY: "${CLOUD_IMAGE_REGISTRY}",
IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}",
BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('RESTORE_FROM_PREVIOUS_JOB', '', 'URL to a previous stopped release job which needs to be continued')
stringParam('KOGITO_VERSION', '', 'Kogito version to release as Major.minor.micro')
stringParam('KOGITO_IMAGES_VERSION', '', '(optional) To be set if different from KOGITO_VERSION. Should be only a bug fix update from KOGITO_VERSION.')
stringParam('KOGITO_OPERATOR_VERSION', '', '(optional) To be set if different from KOGITO_VERSION. Should be only a bug fix update from KOGITO_VERSION.')
stringParam('KOGITO_SERVERLESS_OPERATOR_VERSION', '', '(optional) To be set if different from KOGITO_VERSION. Should be only a bug fix update from KOGITO_VERSION.')
booleanParam('DEPLOY_AS_LATEST', false, 'Given project version is considered the latest version')
stringParam('APPS_URI', '', 'Override default. Git uri to the kogito-apps repository to use for building images.')
stringParam('APPS_REF', '', 'Override default. Git reference (branch/tag) to the kogito-apps repository to use for building images.')
booleanParam('SKIP_TESTS', false, 'Skip all tests')
stringParam('EXAMPLES_URI', '', 'Override default. Git uri to the kogito-examples repository to use for tests.')
stringParam('EXAMPLES_REF', '', 'Override default. Git reference (branch/tag) to the kogito-examples repository to use for tests.')
booleanParam('SKIP_IMAGES_RELEASE', false, 'To skip Images Test & Deployment.')
booleanParam('SKIP_EXAMPLES_IMAGES_RELEASE', false, 'To skip Examples Images Deployment')
booleanParam('SKIP_OPERATOR_RELEASE', false, 'To skip Operator Test & Deployment.')
booleanParam('SKIP_SERVERLESS_OPERATOR_RELEASE', false, 'To skip Serverless Operator Test & Deployment.')
booleanParam('USE_TEMP_OPENSHIFT_REGISTRY', false, 'If enabled, use Openshift registry to push temporary images')
}
}
}
void setupBuildOperatorNode() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'build-operator-node', JobType.TOOLS, "${JENKINSFILE_PATH}/Jenkinsfile.build-operator-node")
KogitoJobTemplate.createPipelineJob(this, jobParams)
}