diff --git a/cicd/bootstrap.sh b/cicd/bootstrap.sh index 060f3a47..29253ead 100644 --- a/cicd/bootstrap.sh +++ b/cicd/bootstrap.sh @@ -19,6 +19,17 @@ export WORKSPACE=${WORKSPACE:-$APP_ROOT} # if running in jenkins, use the build export BONFIRE_ROOT=${WORKSPACE}/bonfire export CICD_ROOT=${BONFIRE_ROOT}/cicd export IMAGE_TAG=$(git rev-parse --short=7 HEAD) + +# if this is a PR, use a different tag, since PR tags expire +if [ ! -z "$ghprbPullId" ]; then + export IMAGE_TAG="pr-${ghprbPullId}-${IMAGE_TAG}" +fi + +if [ ! -z "$gitlabMergeRequestIid" ]; then + export IMAGE_TAG="pr-${gitlabMergeRequestIid}-${IMAGE_TAG}" +fi + + export GIT_COMMIT=$(git rev-parse HEAD) export ARTIFACTS_DIR="$WORKSPACE/artifacts" diff --git a/cicd/build.sh b/cicd/build.sh index 3753b516..e73b394f 100644 --- a/cicd/build.sh +++ b/cicd/build.sh @@ -24,7 +24,10 @@ function build { exit 1 fi - echo "LABEL quay.expires-after=3d" >> $APP_ROOT/$DOCKERFILE # tag expires in 3 days + # if this is a PR, set the tag to expire in 3 days + if [ ! -z "$ghprbPullId" ] || [ ! -z "$gitlabMergeRequestIid" ]; then + echo "LABEL quay.expires-after=3d" >> $APP_ROOT/$DOCKERFILE + fi if test -f /etc/redhat-release && grep -q -i "release 7" /etc/redhat-release; then # on RHEL7, use docker