Skip to content

Commit 976677b

Browse files
committed
Add build-fbc job to build file-based catalogs on Konflux
1 parent 92709c0 commit 976677b

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

jobs/build/build-fbc/Jenkinsfile

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
node() {
2+
checkout scm
3+
def buildlib = load('pipeline-scripts/buildlib.groovy')
4+
def commonlib = buildlib.commonlib
5+
commonlib.describeJob("build-fbc", """
6+
<h2>Build FBC segments for OLM operators on Konflux</h2>
7+
""")
8+
9+
properties([
10+
disableResume(),
11+
[
12+
$class: 'ParametersDefinitionProperty',
13+
parameterDefinitions: [
14+
string(
15+
name: 'ART_TOOLS_COMMIT',
16+
description: 'Override the art-tools submodule; Format is ghuser@commitish e.g. jupierce@covscan-to-podman-2',
17+
defaultValue: "",
18+
trim: true
19+
),
20+
choice(
21+
name: 'BUILD_VERSION',
22+
choices: commonlib.ocpVersions,
23+
description: 'OCP Version',
24+
),
25+
string(
26+
name: 'ASSEMBLY',
27+
description: 'Assembly name.',
28+
defaultValue: "stream",
29+
trim: true,
30+
),
31+
string(
32+
name: 'DOOZER_DATA_PATH',
33+
description: 'ocp-build-data fork to use (e.g. test customizations on your own fork)',
34+
defaultValue: "https://github.com/openshift-eng/ocp-build-data",
35+
trim: true,
36+
),
37+
string(
38+
name: 'DOOZER_DATA_GITREF',
39+
description: '(Optional) Doozer data path git [branch / tag / sha] to use',
40+
defaultValue: "",
41+
trim: true,
42+
),
43+
string(
44+
name: 'OPERATOR_NVRS',
45+
description: '(Optional) List **only** the operator NVRs you want to build bundles for, everything else gets ignored. The operators should not be mode:disabled/wip in ocp-build-data',
46+
defaultValue: "",
47+
trim: true,
48+
),
49+
string(
50+
name: 'ONLY',
51+
description: '(Optional) List **only** the operators you want ' +
52+
'to build, everything else gets ignored.\n' +
53+
'Format: Comma and/or space separated list of brew '+
54+
'packages (e.g.: cluster-nfd-operator-container)\n' +
55+
'Leave empty to build all (except EXCLUDE, if defined)',
56+
defaultValue: '',
57+
trim: true,
58+
),
59+
string(
60+
name: 'EXCLUDE',
61+
description: '(Optional) List the operators you **don\'t** want ' +
62+
'to build, everything else gets built.\n' +
63+
'Format: Comma and/or space separated list of brew ' +
64+
'packages (e.g.: cluster-nfd-operator-container)\n' +
65+
'Leave empty to build all (or ONLY, if defined)',
66+
defaultValue: '',
67+
trim: true,
68+
),
69+
booleanParam(
70+
name: 'DRY_RUN',
71+
description: 'Just show what would happen, without actually executing the steps',
72+
defaultValue: false,
73+
),
74+
booleanParam(
75+
name: 'MOCK',
76+
description: 'Pick up changed job parameters and then exit',
77+
defaultValue: false,
78+
),
79+
], // parameterDefinitions
80+
], // ParametersDefinitionProperty
81+
]) // properties
82+
83+
commonlib.checkMock()
84+
85+
def operator_nvrs = []
86+
def only = []
87+
def exclude = []
88+
89+
stage('Set build info') {
90+
operator_nvrs = commonlib.parseList(params.OPERATOR_NVRS)
91+
only = commonlib.parseList(params.ONLY)
92+
exclude = commonlib.parseList(params.EXCLUDE)
93+
currentBuild.displayName += " (${params.BUILD_VERSION})"
94+
95+
if (params.ASSEMBLY && params.ASSEMBLY != "stream") {
96+
currentBuild.displayName += " - assembly ${params.ASSEMBLY}"
97+
}
98+
}
99+
100+
stage('Import FBC catalog objects') {
101+
script {
102+
// Prepare working dirs
103+
buildlib.init_artcd_working_dir()
104+
def doozer_working = "${WORKSPACE}/doozer_working"
105+
buildlib.cleanWorkdir(doozer_working)
106+
107+
// Create artcd command
108+
withCredentials([
109+
string(credentialsId: 'redis-server-password', variable: 'REDIS_SERVER_PASSWORD'),
110+
string(credentialsId: 'art-bot-slack-token', variable: 'SLACK_BOT_TOKEN'),
111+
file(credentialsId: 'openshift-bot-ocp-konflux-service-account', variable: 'KONFLUX_SA_KUBECONFIG'),
112+
string(credentialsId: 'konflux-art-images-username', variable: 'KONFLUX_ART_IMAGES_USERNAME'),
113+
string(credentialsId: 'konflux-art-images-password', variable: 'KONFLUX_ART_IMAGES_PASSWORD'),
114+
file(credentialsId: 'konflux-gcp-app-creds-prod', variable: 'GOOGLE_APPLICATION_CREDENTIALS'),
115+
]) {
116+
def cmd = [
117+
"artcd",
118+
"-v",
119+
"--working-dir=./artcd_working",
120+
"--config=./config/artcd.toml",
121+
]
122+
if (params.DRY_RUN) {
123+
cmd << "--dry-run"
124+
}
125+
cmd += [
126+
"build-fbc",
127+
"--version=${params.BUILD_VERSION}",
128+
"--assembly=${params.ASSEMBLY}",
129+
"--data-path=${params.DOOZER_DATA_PATH}",
130+
"--data-gitref=${params.DOOZER_DATA_GITREF}",
131+
"--kubeconfig=${env.KONFLUX_SA_KUBECONFIG}",
132+
]
133+
if (only)
134+
cmd << "--only=${only.join(',')}"
135+
if (exclude)
136+
cmd << "--exclude=${exclude.join(',')}"
137+
if (operator_nvrs)
138+
cmd << "--operator-nvrs=${operator_nvrs.join(',')}"
139+
140+
// Run pipeline
141+
timeout(activity: true, time: 60, unit: 'MINUTES') { // if there is no log activity for 1 hour
142+
echo "Will run ${cmd}"
143+
withEnv(["BUILD_URL=${env.BUILD_URL}"]) {
144+
try {
145+
sh(script: cmd.join(' '), returnStdout: true)
146+
} catch (err) {
147+
throw err
148+
} finally {
149+
commonlib.safeArchiveArtifacts([
150+
"artcd_working/**/*.log",
151+
"artcd_working/**/*.yaml",
152+
])
153+
}
154+
} // withEnv
155+
} // timeout
156+
} // withCredentials
157+
} // script
158+
} //stage
159+
} // node

0 commit comments

Comments
 (0)