Skip to content

Commit 513425e

Browse files
ravanellijlebon
authored andcommitted
utils: Add support for image/manifest disgest in related functions
- Add support to create manifests using the image digest instead of tags only; - Update build-node-image job to reflect it. Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
1 parent e309ea9 commit 513425e

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

jobs/build-node-image.Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ lock(resource: "build-node-image") {
6666
def arches = params.ARCHES.split() as Set
6767
def archinfo = arches.collectEntries{[it, [:]]}
6868
def (container_registry_staging_repo, container_registry_repo_and_tag) = pipeutils.get_ocp_node_registry_repo(pipecfg, params.RELEASE)
69-
def container_registry_staging_manifest_tag = "${params.RELEASE}-${shortcommit}"
70-
def container_registry_staging_image_tag = "${params.RELEASE}-${shortcommit}"
69+
def container_registry_staging_manifest_tag = "${params.RELEASE}"
70+
def container_registry_staging_image_tag = "${params.RELEASE}"
7171
def container_registry_staging_manifest = "${container_registry_staging_repo}:${container_registry_staging_manifest_tag}"
7272

7373
// add any additional root CA cert before we do anything that fetches

utils.groovy

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -845,20 +845,25 @@ def build_remote_image(arches, commit, url, repo, tag, secret=None, from=None,
845845
build_args += ["--from", from]
846846
}
847847
build_args += extra_build_args
848+
def digest_list = []
848849
parallel arches.collectEntries { arch ->
849850
[arch, {
850851
pipeutils.withPodmanRemoteArchBuilder(arch: arch) {
851852
def final_args = build_args + ["--arch", arch, "--tag", "${tag}-${arch}"]
853+
final_args += ["--write-digest-to-file", "${tag}-${arch}"]
852854
shwrap("cosa remote-build-container ${final_args.join(' ')}")
855+
digest_list += readFile("${tag}-${arch}")
856+
shwrap("""rm -f ${tag}-${arch} """)
853857
}
854858
}]
855859
}
860+
return digest_list
856861
}
857862

858-
def push_manifest(arches, repo, image_tag, manifest_tag) {
863+
def push_manifest(digests, repo, manifest_tag) {
859864
def images = ""
860-
for (arch in arches) {
861-
images += " --image=docker://${repo}:${image_tag}-${arch}"
865+
for (digest in digests) {
866+
images += " --image=docker://${repo}@${digest}"
862867
}
863868
// arbitrarily selecting the s390x builder; we don't run this
864869
// locally because podman wants user namespacing (yes, even just
@@ -879,23 +884,23 @@ def copy_image(src_image, dest_image, registry_secret_path=None) {
879884
""")
880885
}
881886

882-
def delete_tags(arches, repo, image_tag, manifest_tag, registry_secret_path=None) {
887+
def delete_tags(digests, repo, manifest_tag, registry_secret_path=None) {
883888
shwrap("""
884889
export STORAGE_DRIVER=vfs # https://github.com/coreos/fedora-coreos-pipeline/issues/723#issuecomment-1297668507
885890
skopeo delete --authfile=${registry_secret_path} \
886891
docker://${repo}:${manifest_tag}
887892
""")
888-
parallel arches.keySet().collectEntries{arch -> [arch, {
893+
parallel digests.keySet().collectEntries{arch -> [digest, {
889894
shwrap("""
890895
export STORAGE_DRIVER=vfs # https://github.com/coreos/fedora-coreos-pipeline/issues/723#issuecomment-1297668507
891896
skopeo delete --authfile=${registry_secret_path} \
892-
docker://${repo}:${image_tag}-${arch}
897+
docker://${repo}:${digest}
893898
""")
894899
}]}
895900
}
896901

897902
def build_and_push_image(params = [:]) {
898-
// Available parameters:
903+
// Available parameters:
899904
// arches: list -- List of architectures to run against
900905
// extra_build_args: list -- List of extra commands to pass to `cosa remote` cmd
901906
// from: string -- Value to replace in the Containerfile
@@ -910,12 +915,10 @@ def build_and_push_image(params = [:]) {
910915
def from = params.get('from', "");
911916
def extra_build_args = params.get('extra_build_args', "");
912917

913-
build_remote_image(params['arches'], params['src_commit'], params['src_url'], params['staging_repository'],
914-
params['image_tag_staging'], secret, from, extra_build_args)
915-
918+
def digests = build_remote_image(params['arches'], params['src_commit'], params['src_url'], params['staging_repository'],
919+
params['image_tag_staging'], secret, from, extra_build_args)
916920
stage("Push Manifest") {
917-
push_manifest(params['arches'], params['staging_repository'], params['image_tag_staging'],
918-
params['manifest_tag_staging'])
921+
push_manifest(digests, params['staging_repository'], params['manifest_tag_staging'])
919922
}
920923
}
921924

0 commit comments

Comments
 (0)