Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2035d97

Browse files
committedFeb 17, 2025··
release: allow pushing container images to multipes repositories
In RHCOS we need to publish the oscontainer image to the release repo and also the CI repo. Changing the registry_repo object to be an array instead of a map to allow multiple entries.
1 parent 38614b6 commit 2035d97

File tree

4 files changed

+65
-50
lines changed

4 files changed

+65
-50
lines changed
 

‎config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ s3:
4040

4141
registry_repos:
4242
oscontainer:
43-
repo: quay.io/fedora/fedora-coreos
44-
tags: ["${STREAM}", "${VERSION}"]
43+
- repo: quay.io/fedora/fedora-coreos
44+
tags: ["${STREAM}", "${VERSION}"]
4545
kubevirt:
46-
repo: quay.io/fedora/fedora-coreos-kubevirt
47-
tags: ["${STREAM}"]
46+
- repo: quay.io/fedora/fedora-coreos-kubevirt
47+
tags: ["${STREAM}"]
4848

4949
default_artifacts:
5050
all:

‎docs/config.yaml

+24-14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ streams:
8181
# OPTIONAL: override additional architectures to build for
8282
additional_arches:
8383
- s390x
84+
# OPTIONAL: add OCI registries to upload images to, specific to this stream.
85+
# This will be merged with the `registry_repos` key.
86+
additional_registry_repos:
87+
oscontainer:
88+
- repo: quay.io/someorg/someimage
89+
tags: ["${STREAM}"]
8490
rawhide:
8591
type: mechanical
8692
# OPTIONAL: additional architectures to skip building for
@@ -138,25 +144,29 @@ brew:
138144
registry_repos:
139145
# OPTIONAL: repo and tags to which to push oscontainer
140146
oscontainer:
141-
# REQUIRED: repo name
142-
repo: quay.io/fedora/fedora-coreos
143-
# REQUIRED: list of tags to create/overwrite when pushing
144-
# STREAM and VERSION are supported for templating
145-
tags: ["${STREAM}"]
146-
# OPTIONAL: repo and tags to which to push legacy oscontainer
147+
# REQUIRED: repo name
148+
- repo: quay.io/fedora/fedora-coreos
149+
# REQUIRED: list of tags to create/overwrite when pushing
150+
# STREAM and VERSION are supported for templating
151+
tags: ["${STREAM}"]
152+
# multiple push destinations can be specified
153+
- repo: quay.io/some_other/registry
154+
tags: ["{$STREAM}"]
155+
# OPTIONAL: repo and tags to which to push legacy oscontainer
147156
legacy_oscontainer:
148-
repo: quay.io/openshift-release-dev/rhel-coreos-dev
149-
tags: ["${STREAM}-legacy", "${VERSION}-legacy"]
157+
- repo: quay.io/openshift-release-dev/rhel-coreos-dev
158+
tags: ["${STREAM}-legacy", "${VERSION}-legacy"]
150159
# OPTIONAL: repo and tags to which to push the extensions container
151160
extensions:
152-
repo: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
153-
tags: ["${STREAM}-extensions", "${VERSION}-extensions"]
161+
- repo: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
162+
tags: ["${STREAM}-extensions", "${VERSION}-extensions"]
154163
# OPTIONAL: repo and tags to which to push kubevirt containerdisk container
155164
kubevirt:
156-
repo: quay.io/fedora/fedora-coreos-kubevirt
157-
tags: ["${STREAM}"]
158-
# OPTIONAL: whether to push in v2s2 format rather than OCI
159-
v2s2: true
165+
- repo: quay.io/fedora/fedora-coreos-kubevirt
166+
tags: ["${STREAM}"]
167+
# OPTIONAL: whether to push in v2s2 format rather than OCI
168+
# Default to false if not specified
169+
v2s2: true
160170

161171
# OPTIONAL: cloud-related knobs
162172
clouds:

‎jobs/release.Jenkinsfile

+16-14
Original file line numberDiff line numberDiff line change
@@ -259,26 +259,28 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
259259
if (push_containers) {
260260
stage("Push Containers") {
261261
parallel push_containers.collectEntries{configname, val -> [configname, {
262-
if (!registry_repos?."${configname}"?.'repo') {
262+
if (!registry_repos?."${configname}") {
263263
echo "No registry repo config for ${configname}. Skipping"
264264
return
265265
}
266266
withCredentials([file(variable: 'REGISTRY_SECRET',
267267
credentialsId: 'oscontainer-push-registry-secret')]) {
268-
def repo = registry_repos[configname]['repo']
268+
def repos = registry_repos[configname]
269269
def (artifact, metajsonname) = val
270-
def tag_args = registry_repos[configname].tags.collect{"--tag=$it"}
271-
def v2s2_arg = registry_repos.v2s2 ? "--v2s2" : ""
272-
shwrap("""
273-
export COSA_SUPERMIN_MEMORY=1024 # this really shouldn't require much RAM
274-
cp \${REGISTRY_SECRET} tmp/push-secret-${metajsonname}
275-
cosa supermin-run /usr/lib/coreos-assembler/cmd-push-container-manifest \
276-
--auth=tmp/push-secret-${metajsonname} \
277-
--repo=${repo} ${tag_args.join(' ')} \
278-
--artifact=${artifact} --metajsonname=${metajsonname} \
279-
--build=${params.VERSION} ${v2s2_arg}
280-
rm tmp/push-secret-${metajsonname}
281-
""")
270+
for (repo in repos) {
271+
def tag_args = repo.tags.collect{"--tag=$it"}
272+
def v2s2_arg = repo.v2s2 ? "--v2s2" : ""
273+
shwrap("""
274+
export COSA_SUPERMIN_MEMORY=1024 # this really shouldn't require much RAM
275+
cp \${REGISTRY_SECRET} tmp/push-secret-${metajsonname}
276+
cosa supermin-run /usr/lib/coreos-assembler/cmd-push-container-manifest \
277+
--auth=tmp/push-secret-${metajsonname} \
278+
--repo=${repo.repo} ${tag_args.join(' ')} \
279+
--artifact=${artifact} --metajsonname=${metajsonname} \
280+
--build=${params.VERSION} ${v2s2_arg}
281+
rm tmp/push-secret-${metajsonname}
282+
""")
283+
}
282284
}
283285
}]}
284286
}

‎utils.groovy

+21-18
Original file line numberDiff line numberDiff line change
@@ -516,26 +516,29 @@ def build_artifacts(pipecfg, stream, basearch) {
516516

517517
def get_registry_repos(pipecfg, stream, version) {
518518
def registry_repos = pipecfg.registry_repos ?: [:]
519-
// merge top-level registry_repos with stream-specific bits
520-
registry_repos += pipecfg.streams[stream].additional_registry_repos ?: [:]
521-
for (repo in (registry_repos.keySet() as List)) {
522-
if (repo == 'v2s2') {
523-
// this is a boolean option, not a registry repo
524-
continue
525-
}
526-
if (registry_repos[repo].tags) {
527-
def processed_tags = []
528-
for (tag in registry_repos."${repo}".tags) {
529-
tag = utils.substituteStr(tag, [STREAM: stream, VERSION: version])
530-
if (pipecfg.hotfix) {
531-
// this is a hotfix build; include the hotfix name
532-
// in the tag suffix so we don't clobber official
533-
// tags
534-
tag += "-hotfix-${pipecfg.hotfix.name}"
519+
// get stream-specific bits additional repos
520+
def additional_repos = pipecfg.streams[stream].additional_registry_repos ?: [:]
521+
for (repo_id in (additional_repos.keySet() as List)) {
522+
// merge top-level registry_repos with additional repos
523+
def merged_registry_repos = registry_repos[repo_id] ?: []
524+
registry_repos[repo_id] = merged_registry_repos + (additional_repos[repo_id] ?: [])
525+
}
526+
for (repo_id in (registry_repos.keySet() as List)) {
527+
for (repo in registry_repos[repo_id]) {
528+
if (repo.tags) {
529+
def processed_tags = []
530+
for (tag in repo.tags) {
531+
tag = utils.substituteStr(tag, [STREAM: stream, VERSION: version])
532+
if (pipecfg.hotfix) {
533+
// this is a hotfix build; include the hotfix name
534+
// in the tag suffix so we don't clobber official
535+
// tags
536+
tag += "-hotfix-${pipecfg.hotfix.name}"
537+
}
538+
processed_tags += tag
535539
}
536-
processed_tags += tag
540+
repo.tags = processed_tags
537541
}
538-
registry_repos[repo]['tags'] = processed_tags
539542
}
540543
}
541544
return registry_repos

0 commit comments

Comments
 (0)
Please sign in to comment.