Skip to content

Commit eb97d3d

Browse files
committed
Add the initial code for bootimage bump
1 parent 38614b6 commit eb97d3d

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

jobs/bootimagebump.Jenkinsfile

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
botCreds = "github-coreosbot-releng-token-username-password"
2+
releng_installer = "coreosbot-releng/installer"
3+
4+
node {
5+
checkout scm: [
6+
$class: 'GitSCM',
7+
branches: [[name: "main"]],
8+
userRemoteConfigs: [[url: "https://github.com/${releng_installer}.git"]],
9+
extensions: [
10+
[$class: 'CloneOption', depth: 1, noTags: true, shallow: true],
11+
[$class: 'WipeWorkspace']]
12+
]
13+
14+
properties([
15+
pipelineTriggers([]),
16+
parameters([
17+
string(name: 'STREAM',
18+
description: 'CoreOS stream to build',
19+
defaultValue: '4.16-9.4',
20+
trim: true),
21+
string(name: 'BUILD_VERSION',
22+
description: 'RHCOS build version to use for the bump',
23+
defaultValue: '416.94.202501270445-0',
24+
trim: true),
25+
string(name: 'BOOTIMAGE_BUG_ID',
26+
description: 'JIRA bug ID for the bootimage bump',
27+
defaultValue: 'OCPBUGS-48762',
28+
trim: true),
29+
text(name: 'JIRA_ISSUES',
30+
description: 'JIRA issues for the bootimage bump',
31+
defaultValue: '',
32+
trim: true),
33+
string(name: 'COREOS_ASSEMBLER_IMAGE',
34+
description: 'Override the coreos-assembler image to use',
35+
defaultValue: "quay.io/coreos-assembler/coreos-assembler:rhcos-4.16",
36+
trim: true),
37+
]),
38+
buildDiscarder(logRotator(
39+
numToKeepStr: '100',
40+
artifactNumToKeepStr: '100'
41+
)),
42+
durabilityHint('PERFORMANCE_OPTIMIZED')
43+
])
44+
45+
COSA_IMAGE = "quay.io/coreos-assembler/coreos-assembler:rhcos-${params.STREAM}"
46+
RHCOS_METADATA_FILE = "data/data/coreos/rhcos.json"
47+
PR_BRANCH = "bootimage-bump-${params.BUILD_VERSION}"
48+
RELEASE_BRANCH = "release-${params.STREAM.split('-')[0]}"
49+
50+
cosaPod(serviceAccount: "jenkins",
51+
image: params.COREOS_ASSEMBLER_IMAGE,
52+
memory: "512Mi", kvm: false,){
53+
try {
54+
shwrap("""
55+
git config --global user.name "CoreOS Bot"
56+
git config --global user.email "[email protected]"
57+
""")
58+
// Clone the openshift/installer repository and fetch the required release branch
59+
stage('Setup workspace') {
60+
shwrap("""
61+
git clone --depth=1 --branch main https://github.com/${releng_installer}.git
62+
cd installer
63+
git remote -v
64+
git remote add upstream https://github.com/openshift/installer.git
65+
retries=3
66+
for i in \$(seq 1 \$retries); do
67+
echo "Attempt \$i of \$retries to fetch upstream/${RELEASE_BRANCH}"
68+
git fetch upstream ${RELEASE_BRANCH} && break || sleep 10
69+
done
70+
git checkout -b ${PR_BRANCH} upstream/${RELEASE_BRANCH}
71+
git remote -v
72+
""")
73+
}
74+
75+
// Run plume cosa2stream to update the RHCOS bootimage metadata (rhcos.json)
76+
stage('Bump Bootimage Metadata') {
77+
shwrap("""
78+
cd installer
79+
plume cosa2stream \
80+
--target ${RHCOS_METADATA_FILE} \
81+
--distro rhcos \
82+
--no-signatures \
83+
--name ${params.STREAM} \
84+
--url https://rhcos.mirror.openshift.com/art/storage/prod/streams \
85+
x86_64=${params.BUILD_VERSION} \
86+
aarch64=${params.BUILD_VERSION} \
87+
s390x=${params.BUILD_VERSION} \
88+
ppc64le=${params.BUILD_VERSION}
89+
""")
90+
}
91+
// Commit the updated metadata.
92+
stage('Create Pull Request') {
93+
//if (shwrapCapture("git diff --exit-code") != 0){
94+
def message = "${params.BOOTIMAGE_BUG_ID}: Update RHCOS-${RELEASE_BRANCH} bootimage metadata to ${params.BUILD_VERSION}"
95+
def commit_message = """\
96+
${params.BOOTIMAGE_BUG_ID}: Update RHCOS ${RELEASE_BRANCH} bootimage metadata to ${params.BUILD_VERSION}
97+
98+
The changes done here will update the RHCOS ${RELEASE_BRANCH} bootimage metadata and address the following issues:
99+
${params.JIRA_ISSUES}
100+
101+
This change was generated using:
102+
103+
plume cosa2stream --target ${RHCOS_METADATA_FILE} \\
104+
--distro rhcos --no-signatures --name ${params.STREAM} \\
105+
--url https://rhcos.mirror.openshift.com/art/storage/prod/streams \\
106+
x86_64=${params.BUILD_VERSION} \\
107+
aarch64=${params.BUILD_VERSION} \\
108+
s390x=${params.BUILD_VERSION} \\
109+
ppc64le=${params.BUILD_VERSION}
110+
111+
""".stripIndent()
112+
shwrap ("""
113+
cd installer
114+
git add ${RHCOS_METADATA_FILE}
115+
git commit -m '${commit_message}'
116+
""")
117+
118+
withCredentials([usernamePassword(credentialsId: botCreds,
119+
usernameVariable: 'GHUSER',
120+
passwordVariable: 'GHTOKEN')]) {
121+
shwrap("""
122+
cd installer
123+
git push -f https://\${GHUSER}:\${GHTOKEN}@github.com/${releng_installer} ${PR_BRANCH}
124+
curl -H "Authorization: token ${GHTOKEN}" -X POST -d '{ "title": "${message}", "head": "coreosbot-releng:${PR_BRANCH}", "base": "${RELEASE_BRANCH}" }' https://api.github.com/repos/openshift/installer/pulls --fail
125+
""")
126+
}
127+
//}
128+
currentBuild.result = 'SUCCESS'
129+
}
130+
} catch (e) {
131+
currentBuild.result = 'FAILURE'
132+
throw e
133+
} finally {
134+
def message = "[${params.STREAM}][bootimage-bump] #${env.BUILD_NUMBER} <${env.BUILD_URL}|:jenkins:> <${env.RUN_DISPLAY_URL}|:ocean:>"
135+
if (currentBuild.result == 'SUCCESS') {
136+
message = ":sparkles: ${message}"
137+
} else if (currentBuild.result == 'UNSTABLE') {
138+
message = ":warning: ${message}"
139+
} else {
140+
message = ":fire: ${message}"
141+
}
142+
echo message
143+
//pipeutils.trySlackSend(message: message)
144+
}
145+
}
146+
}

0 commit comments

Comments
 (0)