diff --git a/scripts/promote-image.sh b/scripts/promote-image.sh index d29900e..60cdeeb 100755 --- a/scripts/promote-image.sh +++ b/scripts/promote-image.sh @@ -61,32 +61,33 @@ PROJECT=$(echo ${REGISTRY_URL#*/}/${CONTAINER} | sed s,/,%2F,g) HEADER="Authorization:Basic $(echo -n "${HARBOR_USER}:${HARBOR_PASSWD}" | base64)" -# Try and delete build tag 5 times, with a 10s delay between attempts -# -iter=5 -while (( iter )); do - echo -e "Deleting tag:\n ${CONTAINER}:${TAG}\nFrom:\n ${PROJECT}" - - RESULTS=$(curl --noproxy '*' -s -k \ +delete_tag() { + _project=$1 + _repository=$2 + _tag=$3 + _fqdn=${REGISTRY_URL%%/*} + _repository=${_repository//\//%2F} + curl --noproxy '*' -s -k \ -i \ -X DELETE \ -H "${HEADER}" \ -H "accept: application/json" \ - "https://${FQDN}/api/repositories/${PROJECT}/tags/${TAG}") + "https://${_fqdn}/api/v2.0/projects/${_project}/repositories/${_repository}/artifacts/${_tag}" - if echo ${RESULTS} | grep -q "HTTP.*200"; then - echo "Tag deleted successfully." - break - else - echo "Error deleting tag:" >&2 - echo "${RESULTS}" >&2 - iter=$((iter-1)) - if (( ! iter )); then - fail "No more tries." - fi - echo "Waiting 10s before trying again..." - sleep 10 - fi +# To just delete the tag and not the image, use: +# "https://${_fqdn}/api/v2.0/projects/${_project}/repositories/${_repository}/artifacts/${_tag}/tags/${_tag}" +} + +echo -e "Deleting tag:\n vtt-osgc solutions/${CONTAINER}:${TAG}\nFrom:\n ${PROJECT}" + +RESULTS=$(delete_tag vtt-osgc solutions/${CONTAINER} ${TAG}) + +if echo ${RESULTS} | grep -q "HTTP.*200"; then + echo "Tag deleted successfully." + break +else + echo "Error deleting tag:" >&2 + echo "${RESULTS}" >&2 done iter=5 diff --git a/scripts/trigger.sh b/scripts/trigger.sh index 9857140..16a0603 100755 --- a/scripts/trigger.sh +++ b/scripts/trigger.sh @@ -28,14 +28,18 @@ Usage: scripts/trigger.sh [OPTIONS] Options: - -h Help - -q Quiet - -p PROJECT Project to trigger GitLab CI - + -h This text + -p PROJECT Project name. + Default: Current directory name + -q Quiet output (for use in scripting.) Only output + pipeline ID (if successfully started.) + -y Answer Yes to any prompts + -g GROUP Group path under GitLab URL + Default: vtt/sws/osgc/solutions EOF } -while getopts ydqp:h opt; do +while getopts ydqp:hg: opt; do case "${opt}" in h) usage @@ -44,6 +48,9 @@ while getopts ydqp:h opt; do q) QUIET=1 ;; + g) + GROUP=${OPTARG} + ;; p) PROJECT=${OPTARG} ;; @@ -91,7 +98,8 @@ REF=${REF:-master} PROJECT=${PROJECT:-${CONTAINER}} PROJECT=${PROJECT:-$(basename $(pwd))} -PROJECT="vtt/sws/osgc/solutions/${PROJECT}" +GROUP=${GROUP:-"vtt/sws/osgc/solutions"} +PROJECT="${GROUP}/${PROJECT}" URI_PROJECT=$(echo ${PROJECT} | sed -E 's,/,%2F,g') eval $(grep ^SYS_OSGC_TOKEN SECRETS) diff --git a/templates/99-env.in b/templates/99-env.in index 49f43b2..e0a07eb 100644 --- a/templates/99-env.in +++ b/templates/99-env.in @@ -5,3 +5,5 @@ ENV GPGPU_PACKAGE_REPOSITORY "${PACKAGE_REPOSITORY}" ENV GPGPU_PACKAGE_STREAM "${PACKAGE_STREAM}" ENV GPGPU_PACKAGE_DISTRO "${OS_DISTRO}" ENV GPGPU_PACKAGE_DISTRO_RELEASE "${OS_RELEASE}" + +USER user diff --git a/templates/centos/25-create-user.in b/templates/centos/18-create-user.in similarity index 98% rename from templates/centos/25-create-user.in rename to templates/centos/18-create-user.in index 4fdb0e7..b4e6c8d 100644 --- a/templates/centos/25-create-user.in +++ b/templates/centos/18-create-user.in @@ -17,5 +17,3 @@ RUN groupadd -r user \ # Set 'wheel' to NOPASSWD for all container users RUN sed -i -e 's,%wheel.*,%wheel ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers - -USER user diff --git a/templates/rhel/25-create-user.in b/templates/rhel/18-create-user.in similarity index 97% rename from templates/rhel/25-create-user.in rename to templates/rhel/18-create-user.in index 508db9d..64c5a0f 100644 --- a/templates/rhel/25-create-user.in +++ b/templates/rhel/18-create-user.in @@ -16,5 +16,3 @@ RUN groupadd -r user \ # Set 'wheel' to NOPASSWD for all container users RUN sed -i -e 's,%wheel.*,%wheel ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers - -USER user diff --git a/templates/sles/25-create-user.in b/templates/sles/18-create-user.in similarity index 98% rename from templates/sles/25-create-user.in rename to templates/sles/18-create-user.in index 81ca9da..0bc0aa8 100644 --- a/templates/sles/25-create-user.in +++ b/templates/sles/18-create-user.in @@ -31,5 +31,3 @@ RUN sed -i -e 's,^ALL.*,%users ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers # Needed for env values set which are needed by the base OS, eg zypper # and *_proxy *_PROXY... RUN echo "Defaults !env_reset" >> /etc/sudoers - -USER user diff --git a/templates/ubuntu/25-create-user.in b/templates/ubuntu/18-create-user.in similarity index 98% rename from templates/ubuntu/25-create-user.in rename to templates/ubuntu/18-create-user.in index 2df6ead..13f1d22 100644 --- a/templates/ubuntu/25-create-user.in +++ b/templates/ubuntu/18-create-user.in @@ -28,5 +28,3 @@ RUN sed -i -e 's,%sudo.*,%sudo ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers RUN apt-get clean \ && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} - -USER user