Skip to content

Commit 472ef9b

Browse files
ravanellijlebon
authored andcommitted
jobs/build-node-image: Add Brew stage
- Add Brew stage in order to upload metadata to Brew. - It will upload meta.json and extensions.json for the node layer image. Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
1 parent b143caa commit 472ef9b

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

jobs/build-node-image.Jenkinsfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def src_config_url = stream_info.source_config.url
5151
lock(resource: "build-node-image") {
5252
cosaPod(image: params.COREOS_ASSEMBLER_IMAGE,
5353
memory: "512Mi", kvm: false,
54-
serviceAccount: "jenkins") {
54+
serviceAccount: "jenkins",
55+
secrets: ["brew-keytab", "brew-ca:ca.crt:/etc/pki/ca.crt",
56+
"koji-conf:koji.conf:/etc/koji.conf",
57+
"krb5-conf:krb5.conf:/etc/krb5.conf"]) {
5558
timeout(time: 45, unit: 'MINUTES') {
5659
try {
5760

@@ -142,6 +145,11 @@ lock(resource: "build-node-image") {
142145
"--git-containerfile", "extensions/Dockerfile", "--force"] + label_args)
143146
}
144147
}
148+
stage("Brew Upload") {
149+
// Use the staging since we already have the disgests
150+
pipeutils.brew_upload(arches, params.RELEASE, registry_staging_repo, node_image_manifest_digest,
151+
extensions_image_manifest_digest, timestamp, pipecfg)
152+
}
145153
stage("Release Manifests") {
146154
withCredentials([file(credentialsId: 'oscontainer-push-registry-secret', variable: 'REGISTRY_AUTH_FILE')]) {
147155
// copy the extensions first as the node image existing is a signal

utils.groovy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,45 @@ def build_and_push_image(params = [:]) {
965965
return manifest_digest
966966
}
967967

968+
def get_arch_image_digest(from) {
969+
return readJSON(text: shwrapCapture("""
970+
skopeo inspect --raw docker://${from} | \
971+
jq -r '.manifests | map({(.platform.architecture): .digest}) | add'
972+
"""))
973+
}
974+
975+
def brew_upload(arches, release, repo, manifest_digest, extensions_manifest_digest, version, pipecfg) {
976+
def node_digest_arch_map = get_arch_image_digest("${repo}@${manifest_digest}")
977+
def extensions_node_digest_arch_map = get_arch_image_digest("${repo}@${extensions_manifest_digest}")
978+
def archAliasMap = [
979+
"x86_64" : "amd64",
980+
"aarch64" : "arm64",
981+
"s390x" : "s390x",
982+
"ppc64le" : "ppc64le"
983+
]
984+
for (arch in arches) {
985+
def inspect_arch = archAliasMap[arch]
986+
def node_image = "${repo}@${node_digest_arch_map[inspect_arch]}"
987+
def extensions_node_image = "${repo}@${extensions_node_digest_arch_map[inspect_arch]}"
988+
989+
// Get metadata files with package information
990+
shwrap("""oc image extract $node_image[-1] --file /usr/share/openshift/base/meta.json
991+
oc image extract $extensions_node_image[-1] --file usr/share/rpm-ostree/extensions.json
992+
""")
993+
shwrap("""
994+
coreos-assembler koji-upload \
995+
upload --reserve-id \
996+
--keytab "/run/kubernetes/secrets/brew-keytab/brew.keytab" \
997+
--build $release-${version} \
998+
--retry-attempts 6 \
999+
--buildroot . \
1000+
--owner ${pipecfg.brew.principal} \
1001+
--profile ${pipecfg.brew.profile} \
1002+
--tag ${pipecfg.streams[release].brew_tag} \
1003+
--arch ${arch} \
1004+
--node-image
1005+
""")
1006+
}
1007+
}
1008+
9681009
return this

0 commit comments

Comments
 (0)