Commit e8c9f75e authored by Benjamin Tissoires's avatar Benjamin Tissoires
Browse files

Add labels to generated images



This should help us to know if the image has been built during this
pipeline, and might come in handy in the future.

Fix #8
Signed-off-by: Benjamin Tissoires's avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
parent 8becba49
......@@ -181,6 +181,43 @@ do not rebuild alpine:latest@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels alpine:latest:
extends:
- alpine:latest@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- alpine:latest@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -153,6 +153,43 @@ do not rebuild arch:rolling@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels arch:rolling:
extends:
- arch:rolling@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- arch:rolling@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -154,6 +154,43 @@ do not rebuild centos:7@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels centos:7:
extends:
- centos:7@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- centos:7@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -252,6 +252,43 @@ do not rebuild debian:stretch@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels debian:stretch:
extends:
- debian:stretch@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- debian:stretch@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -252,6 +252,43 @@ do not rebuild fedora:31@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels fedora:31:
extends:
- fedora:31@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- fedora:31@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -252,6 +252,43 @@ do not rebuild ubuntu:19.10@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels ubuntu:19.10:
extends:
- ubuntu:19.10@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- ubuntu:19.10@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -266,6 +266,43 @@ do not rebuild {{distribution}}:{{ versions[0] }}@container-build:
- sanity check
#
# check if the labels were correctly applied
#
check labels {{distribution}}:{{ versions[0] }}:
extends:
- {{distribution}}:{{ versions[0] }}@check
image: $CI_REGISTRY_IMAGE/buildah:$BOOTSTRAP_TAG
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
# retrieve the infos from the registry (once)
- JSON_IMAGE=$(skopeo inspect docker://$DISTRO_IMAGE)
# parse all the labels we care about
- IMAGE_PIPELINE_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.pipeline_id"]')
- IMAGE_JOB_ID=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.job_id"]')
- IMAGE_PROJECT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.project"]')
- IMAGE_COMMIT=$(echo $JSON_IMAGE | jq -r '.Labels["fdo.commit"]')
# some debug information
- echo $JSON_IMAGE
- echo $IMAGE_PIPELINE_ID $CI_PIPELINE_ID
- echo $IMAGE_JOB_ID
- echo $IMAGE_PROJECT $CI_PROJECT_PATH
- echo $IMAGE_COMMIT $CI_COMMIT_SHA
# ensure the labels are correct (we are on the same pipeline)
- '[[ x"$IMAGE_PIPELINE_ID" == x"$CI_PIPELINE_ID" ]]'
- '[[ x"$IMAGE_JOB_ID" != x"" ]]' # we don't know the job ID, but it must be set
- '[[ x"$IMAGE_PROJECT" == x"$CI_PROJECT_PATH" ]]'
- '[[ x"$IMAGE_COMMIT" == x"$CI_COMMIT_SHA" ]]'
needs:
- {{distribution}}:{{ versions[0] }}@container-build
- sanity check
#
# make sure we do not rebuild the image if the tag exists in the upstream
# repository (during the check)
......
......@@ -289,6 +289,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -256,6 +256,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -256,6 +256,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -261,6 +261,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -271,6 +271,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -261,6 +261,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
......@@ -270,6 +270,11 @@
buildah config -l fdo.upstream-repo=$FDO_UPSTREAM_REPO $buildcntr;
fi
- buildah config -l fdo.pipeline_id="$CI_PIPELINE_ID" $buildcntr;
- buildah config -l fdo.job_id="$CI_JOB_ID" $buildcntr;
- buildah config -l fdo.project="$CI_PROJECT_PATH" $buildcntr;
- buildah config -l fdo.commit="$CI_COMMIT_SHA" $buildcntr;
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment