forked from adoptium/ci-jenkins-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_job_from_template.groovy
206 lines (193 loc) · 12 KB
/
create_job_from_template.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
/*
Licensed 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
https://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.
*/
/**
* A template that defines a build job.
*
* This mostly is just a wrapper to call the openjdk_build_pipeline.groovy script that defines the majority of
* what a pipeline job does
*/
String buildFolder = "$JOB_FOLDER"
if (!binding.hasVariable('GIT_URL')) {
GIT_URL = 'https://github.com/adoptium/ci-jenkins-pipelines.git'
}
if (!binding.hasVariable('GIT_BRANCH')) {
GIT_BRANCH = 'master'
}
//TODO: need more logic to handle when it is a tag in format of "refs/tags/<tagName>"
if (binding.hasVariable('CHECKOUT_AS_TAG')) {
GIT_BRANCH = "refs/heads/"+GIT_BRANCH
}
isLightweight = true
if (binding.hasVariable('PR_BUILDER')) {
isLightweight = false
}
folder(buildFolder) {
description 'Automatically generated build jobs.'
}
pipelineJob("$buildFolder/$JOB_NAME") {
description('<h1>THIS IS AN AUTOMATICALLY GENERATED JOB DO NOT MODIFY, IT WILL BE OVERWRITTEN.</h1><p>This job is defined in create_job_from_template.groovy in the ci-jenkins-pipelines repo, if you wish to change it modify that</p>')
definition {
cpsScm {
scm {
git {
remote {
url(GIT_URL)
refspec(' +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/master:refs/remotes/origin/master +refs/heads/*:refs/remotes/origin/*')
credentials("${CHECKOUT_CREDENTIALS}")
}
branch("${GIT_BRANCH}")
extensions {
//repo clean is performed after scm checkout in pipelines/build/common/openjdk_build_pipeline.groovy
pruneStaleBranch()
}
}
}
scriptPath("${SCRIPT_PATH}")
lightweight(isLightweight)
}
}
properties {
// Hide all non Temurin builds or release builds from public view on the Adoptium CI instance
if ((JENKINS_URL.contains('adopt') && (VARIANT != 'temurin')) || ((JENKINS_URL.contains('adopt') && JOB_NAME.contains('release')))) {
authorizationMatrix {
inheritanceStrategy {
// Do not inherit permissions from global configuration
nonInheriting()
}
entries {
group {
name('AdoptOpenJDK*build')
permissions(
[
'Job/Build', // 'hudson.model.Item.Build'
'Job/Cancel', // 'hudson.model.Item.Cancel'
'Job/Configure', // 'hudson.model.Item.Configure'
'Job/Read', // 'hudson.model.Item.Read'
'Job/Workspace', // 'hudson.model.Item.Workspace'
'Run/Update' // 'hudson.model.Run.Update'
])
}
group {
name('AdoptOpenJDK*build-triage')
permissions(
[
'Job/Build', // 'hudson.model.Item.Build'
'Job/Cancel', // 'hudson.model.Item.Cancel'
'Job/Configure', // 'hudson.model.Item.Configure'
'Job/Read', // 'hudson.model.Item.Read'
'Job/Workspace', // 'hudson.model.Item.Workspace'
'Run/Update' // 'hudson.model.Run.Update'
])
}
// eclipse-temurin-bot needs read access for TRSS
user {
name('eclipse-temurin-bot')
permissions(
[
'Job/Read' // 'hudson.model.Item.Read'
])
}
// eclipse-temurin-compliance bot needs read access for https://ci.eclipse.org/temurin-compliance for copying artifacts
user {
name('eclipse-temurin-compliance-bot')
permissions(
[
'Job/Read' // 'hudson.model.Item.Read'
])
}
}
//permissions([
//'GROUP:hudson.model.Item.Build:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Item.Build:AdoptOpenJDK*build-triage', MIGRATED
//'GROUP:hudson.model.Item.Cancel:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Item.Cancel:AdoptOpenJDK*build-triage', MIGRATED
//'GROUP:hudson.model.Item.Configure:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Item.Configure:AdoptOpenJDK*build-triage', MIGRATED
//'GROUP:hudson.model.Item.Read:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Item.Read:AdoptOpenJDK*build-triage', MIGRATED
// eclipse-temurin-bot needs read access for TRSS
//'USER:hudson.model.Item.Read:eclipse-temurin-bot', MIGRATED
// eclipse-temurin-compliance bot needs read access for https://ci.eclipse.org/temurin-compliance
//'USER:hudson.model.Item.Read:eclipse-temurin-compliance-bot', MIGRATED
//'GROUP:hudson.model.Item.Workspace:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Item.Workspace:AdoptOpenJDK*build-triage', MIGRATED
//'GROUP:hudson.model.Run.Update:AdoptOpenJDK*build', MIGRATED
//'GROUP:hudson.model.Run.Update:AdoptOpenJDK*build-triage']) MIGRATED
}
}
disableConcurrentBuilds()
copyArtifactPermission {
projectNames('*')
}
}
logRotator {
numToKeep(30)
artifactNumToKeep(1)
}
parameters {
textParam('BUILD_CONFIGURATION', "$BUILD_CONFIG", """
<dl>
<dt><strong>ARCHITECTURE</strong></dt><dd>x64, ppc64, s390x...</dd>
<dt><strong>TARGET_OS</strong></dt><dd>windows, linux, aix...</dd>
<dt><strong>VARIANT</strong></dt><dd>hotspot, openj9...</dd>
<dt><strong>JAVA_TO_BUILD</strong></dt><dd>i.e jdk11u, jdk12u...</dd>
<dt><strong>TEST_LIST</strong></dt><dd>Comma separated list of tests, i.e: sanity.openjdk,sanity.perf,sanity.system</dd>
<dt><strong>DYNAMIC_LIST</strong></dt><dd>Comma separated list of tests, i.e: sanity.openjdk,sanity.perf,sanity.system</dd>
<dt><strong>NUM_MACHINES</strong></dt><dd>The number of machines for parallel=dynamic</dd>
<dt><strong>SCM_REF</strong></dt><dd>Source code ref to build, i.e branch, tag, commit id.</dd>
<dt><strong>BUILD_REF</strong></dt><dd>Specify temurin-build tag or branch or SHA1.</dd>
<dt><strong>CI_REF</strong></dt><dd>Specify ci-jenkins-pipeline tag or branch or SHA1.</dd>
<dt><strong>HELPER_REF</strong></dt><dd>Specify jenkins-helper tag or branch (we only support these two formats).</dd>
<dt><strong>AQA_REF</strong></dt><dd>Specific aqa-tests release or branch.</dd>
<dt><strong>AQA_AUTO_GEN</strong></dt><dd>If true, froce auto generate AQA test jobs.</dd>
<dt><strong>BUILD_ARGS</strong></dt><dd>args to pass to makejdk-any-platform.sh</dd>
<dt><strong>NODE_LABEL</strong></dt><dd>Labels of node to build on</dd>
<dt><strong>ADDITIONAL_TEST_LABEL</strong></dt><dd>Additional label for test jobs</dd>
<dt><strong>KEEP_TEST_REPORTDIR</strong></dt><dd>If true, test report dir (including core files where generated) will be kept even when the testcase passes, failed testcases always keep the report dir. Does not apply to JUnit jobs which are always kept, eg.openjdk.</dd>
<dt><strong>ACTIVE_NODE_TIMEOUT</strong></dt><dd>Number of minutes we will wait for a label-matching node to become active.</dd>
<dt><strong>CODEBUILD</strong></dt><dd>Use a dynamic codebuild machine if no other machine is available</dd>
<dt><strong>DOCKER_IMAGE</strong></dt><dd>Use a docker build environment</dd>
<dt><strong>DOCKER_ARGS</strong></dt><dd>Additional args to be used in conjuction with DOCKER_IMAGE</dd>
<dt><strong>DOCKER_FILE</strong></dt><dd>Relative path to a dockerfile to be built and used on top of the DOCKER_IMAGE</dd>
<dt><strong>DOCKER_REGISTRY</strong></dt><dd>Custom Docker registry to pull DOCKER_IMAGE from</dd>
<dt><strong>DOCKER_CREDENTIAL</strong></dt><dd>Username & Password Jenkins credential ID for Docker registry login</dd>
<dt><strong>PLATFORM_CONFIG_LOCATION</strong></dt><dd>Repo owner, branch name and relative path to the platform specific configuration for the particular OS you are building (e.g. M-Davies/openjdk-build/my_branch/build-farm/platform-specific-configurations/linux.sh)</dd>
<dt><strong>CONFIGURE_ARGS</strong></dt><dd>Arguments for ./configure. Escape all speech marks used within this parameter.</dd>
<dt><strong>OVERRIDE_FILE_NAME_VERSION</strong></dt><dd>Set the version string on the file name</dd>
<dt><strong>USE_ADOPT_SHELL_SCRIPTS</strong></dt><dd>Use Adopt's make-adopt-build-farm.sh and other bash scripts</dd>
<dt><strong>RELEASE</strong></dt><dd>Is this build a release</dd>
<dt><strong>PUBLISH_NAME</strong></dt><dd>Set name of publish</dd>
<dt><strong>ADOPT_BUILD_NUMBER</strong></dt><dd>Adopt build number</dd>
<dt><strong>ENABLE_REPRODUCIBLE_COMPARE</strong></dt><dd>Run reproducible compare build</dd>
<dt><strong>ENABLE_TESTS</strong></dt><dd>Run tests</dd>
<dt><strong>ENABLE_TESTDYNAMICPARALLEL</strong></dt><dd>Run parallel</dd>
<dt><strong>ENABLE_INSTALLERS</strong></dt><dd>Run installers</dd>
<dt><strong>ENABLE_SIGNER</strong></dt><dd>Run signer</dd>
<dt><strong>CLEAN_WORKSPACE</strong></dt><dd>Wipe out workspace before build</dd>
<dt><strong>CLEAN_WORKSPACE_AFTER</strong></dt><dd>Wipe out workspace after build</dd>
<dt><strong>CLEAN_WORKSPACE_BUILD_OUTPUT_ONLY_AFTER</strong></dt><dd>Wipe out workspace build output only, after build</dd>
</dl>
""")
textParam('USER_REMOTE_CONFIGS', "$USER_REMOTE_CONFIGS", """
<strong>DO NOT ALTER THIS PARAM UNLESS YOU KNOW WHAT YOU ARE DOING!</strong> This passes down the user's git checkout configs to the downstream job.
""")
textParam('DEFAULTS_JSON', "$DEFAULTS_JSON", """
<strong>DO NOT ALTER THIS PARAM UNLESS YOU KNOW WHAT YOU ARE DOING!</strong> This passes the user's default constants to the downstream job.
""")
textParam('ADOPT_DEFAULTS_JSON', "$ADOPT_DEFAULTS_JSON", """
<strong>DO NOT ALTER THIS PARAM UNDER ANY CIRCUMSTANCES!</strong> This passes down adopt's default constants to the downstream job. NOTE: <code>DEFAULTS_JSON</code> has priority, the constants contained within this param will only be used as a failsafe.
""")
if (binding.hasVariable('CUSTOM_BASEFILE_LOCATION')) {
stringParam('CUSTOM_BASEFILE_LOCATION', "$CUSTOM_BASEFILE_LOCATION")
}
}
}