Skip to content

Commit 6a88c81

Browse files
committed
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 6a88c81

File tree

4 files changed

+53
-42
lines changed

4 files changed

+53
-42
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

+15-12
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,26 @@ brew:
138138
registry_repos:
139139
# OPTIONAL: repo and tags to which to push oscontainer
140140
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
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+
# multiple push destinations can be specified
147+
- repo: quay.io/some_other/registry
148+
tags: ["{$STREAM}"]
149+
# OPTIONAL: repo and tags to which to push legacy oscontainer
147150
legacy_oscontainer:
148-
repo: quay.io/openshift-release-dev/rhel-coreos-dev
149-
tags: ["${STREAM}-legacy", "${VERSION}-legacy"]
151+
- repo: quay.io/openshift-release-dev/rhel-coreos-dev
152+
tags: ["${STREAM}-legacy", "${VERSION}-legacy"]
150153
# OPTIONAL: repo and tags to which to push the extensions container
151154
extensions:
152-
repo: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
153-
tags: ["${STREAM}-extensions", "${VERSION}-extensions"]
155+
- repo: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
156+
tags: ["${STREAM}-extensions", "${VERSION}-extensions"]
154157
# OPTIONAL: repo and tags to which to push kubevirt containerdisk container
155158
kubevirt:
156-
repo: quay.io/fedora/fedora-coreos-kubevirt
157-
tags: ["${STREAM}"]
159+
- repo: quay.io/fedora/fedora-coreos-kubevirt
160+
tags: ["${STREAM}"]
158161
# OPTIONAL: whether to push in v2s2 format rather than OCI
159162
v2s2: true
160163

jobs/release.Jenkinsfile

+15-13
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}"?.isEmpty()) {
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"}
271270
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-
""")
271+
for (repo in repos) {
272+
def tag_args = repo.tags.collect{"--tag=$it"}
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

+19-13
Original file line numberDiff line numberDiff line change
@@ -516,26 +516,32 @@ 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 ?: [:]
519+
// get stream-specific bits additional repos
520+
def additional_repos = pipecfg.streams[stream].additional_registry_repos ?: [:]
521+
for (repo in ['oscontainer', 'legacy_oscontainer', 'extensions', 'kubevirt']) {
522+
//merge top-level registry_repos with addtional repos
523+
registry_repos[repo] += additional_repos[repo] ?: []
524+
}
521525
for (repo in (registry_repos.keySet() as List)) {
522526
if (repo == 'v2s2') {
523527
// this is a boolean option, not a registry repo
524528
continue
525529
}
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}"
530+
for (entry in registry_repo[repo]) {
531+
if (entry.tags) {
532+
def processed_tags = []
533+
for (tag in entry.tags) {
534+
tag = utils.substituteStr(tag, [STREAM: stream, VERSION: version])
535+
if (pipecfg.hotfix) {
536+
// this is a hotfix build; include the hotfix name
537+
// in the tag suffix so we don't clobber official
538+
// tags
539+
tag += "-hotfix-${pipecfg.hotfix.name}"
540+
}
541+
processed_tags += tag
535542
}
536-
processed_tags += tag
543+
entry.['tags'] = processed_tags
537544
}
538-
registry_repos[repo]['tags'] = processed_tags
539545
}
540546
}
541547
return registry_repos

0 commit comments

Comments
 (0)