Skip to content

Commit e2aee23

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

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

jobs/bootimagebump.Jenkinsfile

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
// these are script global vars
15+
properties([
16+
pipelineTriggers([]),
17+
parameters([
18+
string(name: 'STREAM',
19+
description: 'CoreOS stream to build',
20+
defaultValue: '4.16-9.4',
21+
trim: true),
22+
string(name: 'BUILD_VERSION',
23+
description: 'RHCOS build version to use for the bump',
24+
defaultValue: '416.94.202501270445-0',
25+
trim: true),
26+
string(name: 'BOOTIMAGE_BUG_ID',
27+
description: 'JIRA bug ID for the bootimage bump',
28+
defaultValue: 'OCPBUGS-48762',
29+
trim: true),
30+
text(name: 'JIRA_ISSUES',
31+
description: 'JIRA issues for the bootimage bump',
32+
defaultValue: '',
33+
trim: true),
34+
string(name: 'COREOS_ASSEMBLER_IMAGE',
35+
description: 'Override the coreos-assembler image to use',
36+
defaultValue: "quay.io/coreos-assembler/coreos-assembler:rhcos-4.16",
37+
trim: true),
38+
]),
39+
buildDiscarder(logRotator(
40+
numToKeepStr: '100',
41+
artifactNumToKeepStr: '100'
42+
)),
43+
durabilityHint('PERFORMANCE_OPTIMIZED')
44+
])
45+
46+
COSA_IMAGE = "quay.io/coreos-assembler/coreos-assembler:rhcos-${params.STREAM}"
47+
RHCOS_METADATA_FILE = "data/data/coreos/rhcos.json"
48+
PR_BRANCH = "bootimage-bump-${params.BUILD_VERSION}"
49+
RELEASE_BRANCH = "release-${params.STREAM.split('-')[0]}"
50+
51+
cosaPod(serviceAccount: "jenkins",
52+
image: params.COREOS_ASSEMBLER_IMAGE,
53+
memory: "512Mi", kvm: false,){
54+
try {
55+
shwrap("""
56+
git config --global user.name "CoreOS Bot"
57+
git config --global user.email "[email protected]"
58+
""")
59+
60+
stage('Setup workspace') {
61+
echo " AR - Cloning openshift/installer repo"
62+
shwrap("""
63+
git clone --depth=1 --branch main https://github.com/${releng_installer}.git
64+
cd installer
65+
git remote -v
66+
git remote add upstream https://github.com/openshift/installer.git
67+
for i in {1..3}; do
68+
git fetch upstream ${RELEASE_BRANCH} && break || { echo "\$i failed, retrying..."; sleep 10; }
69+
done
70+
git checkout -b ${PR_BRANCH} upstream/${RELEASE_BRANCH}
71+
git remote -v
72+
""")
73+
}
74+
75+
stage('Bump Bootimage Metadata') {
76+
echo "AR - Run plume cosa2stream to bump RHCOS 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+
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+
echo "AR - Create PR | rel - ${RELEASE_BRANCH}"
113+
shwrap ("""
114+
cd installer
115+
git add ${RHCOS_METADATA_FILE}
116+
git commit -m '${commit_message}'
117+
""")
118+
echo "git Committed"
119+
withCredentials([usernamePassword(credentialsId: botCreds,
120+
usernameVariable: 'GHUSER',
121+
passwordVariable: 'GHTOKEN')]) {
122+
echo "AR - Push begin"
123+
shwrap("""
124+
cd installer
125+
git push -f https://\${GHUSER}:\${GHTOKEN}@github.com/${releng_installer} ${PR_BRANCH}
126+
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
127+
""")
128+
}
129+
}
130+
currentBuild.result = 'SUCCESS'
131+
}
132+
} catch (e) {
133+
currentBuild.result = 'FAILURE'
134+
throw e
135+
} finally {
136+
def message = "[${params.STREAM}][bootimage-bump] #${env.BUILD_NUMBER} <${env.BUILD_URL}|:jenkins:> <${env.RUN_DISPLAY_URL}|:ocean:>"
137+
if (currentBuild.result == 'SUCCESS') {
138+
message = ":sparkles: ${message}"
139+
} else if (currentBuild.result == 'UNSTABLE') {
140+
message = ":warning: ${message}"
141+
} else {
142+
message = ":fire: ${message}"
143+
}
144+
echo message
145+
//pipeutils.trySlackSend(message: message)
146+
}
147+
}
148+
}

0 commit comments

Comments
 (0)