[igt-dev] [PATCH i-g-t 1/2] gitlab-ci/pull-or-rebuild: added braces for variables
Kamil Konieczny
kamil.konieczny at linux.intel.com
Thu Aug 31 15:35:16 UTC 2023
Added braces for all shell variables.
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
.gitlab-ci/pull-or-rebuild.sh | 40 +++++++++++++++++------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/.gitlab-ci/pull-or-rebuild.sh b/.gitlab-ci/pull-or-rebuild.sh
index 4f77431b5..31f3dbca4 100755
--- a/.gitlab-ci/pull-or-rebuild.sh
+++ b/.gitlab-ci/pull-or-rebuild.sh
@@ -26,41 +26,41 @@ DOCKERFILE=$2
NAME=$3
REF=${4:-${CI_COMMIT_REF_NAME:-latest}}
-REF=$(echo $REF | tr / - )
-IMAGENAME=$CI_REGISTRY/$CI_PROJECT_PATH/$NAME
-DOCKERFILE_CHECKSUM=$(sha1sum $DOCKERFILE | cut -d ' ' -f1)
+REF=$(echo ${REF} | tr / - )
+IMAGENAME=${CI_REGISTRY}/${CI_PROJECT_PATH}/${NAME}
+DOCKERFILE_CHECKSUM=$(sha1sum ${DOCKERFILE} | cut -d ' ' -f1)
-REFNAME=$IMAGENAME:$REF
-DOCKERNAME=$IMAGENAME:dockerfile-$DOCKERFILE_CHECKSUM
-COMMITNAME=$IMAGENAME:commit-$CI_COMMIT_SHA
+REFNAME=${IMAGENAME}:${REF}
+DOCKERNAME=${IMAGENAME}:dockerfile-${DOCKERFILE_CHECKSUM}
+COMMITNAME=${IMAGENAME}:commit-${CI_COMMIT_SHA}
-PODMAN_BUILD="podman build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA --build-arg=CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE"
+PODMAN_BUILD="podman build --build-arg=CI_COMMIT_SHA=${CI_COMMIT_SHA} --build-arg=CI_REGISTRY_IMAGE=${CI_REGISTRY_IMAGE}"
-if [ "$TYPE" = "base" ]; then
+if [ "${TYPE}" = "base" ]; then
# base container (building, etc) - we rebuild only if changed or forced
- skopeo inspect docker://$DOCKERNAME
+ skopeo inspect docker://${DOCKERNAME}
IMAGE_PRESENT=$?
set -e
- if [ $IMAGE_PRESENT -eq 0 ] && [ ${FORCE_REBUILD:-0} -eq 0 ] ; then
+ if [ ${IMAGE_PRESENT} -eq 0 ] && [ ${FORCE_REBUILD:-0} -eq 0 ] ; then
echo "Skipping, already built"
else
echo "Building!"
- $PODMAN_BUILD --squash -t $DOCKERNAME -f $DOCKERFILE .
- podman push $DOCKERNAME
+ ${PODMAN_BUILD} --squash -t ${DOCKERNAME} -f ${DOCKERFILE} .
+ podman push ${DOCKERNAME}
fi
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$DOCKERNAME docker://$COMMITNAME
-elif [ "$TYPE" = "igt" ]; then
+ skopeo copy --dest-creds ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} \
+ docker://${DOCKERNAME} docker://${COMMITNAME}
+elif [ "${TYPE}" = "igt" ]; then
# container with IGT, we don't care about Dockerfile changes
# we always rebuild
set -e
- $PODMAN_BUILD -t $COMMITNAME -f $DOCKERFILE .
- podman push $COMMITNAME
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$COMMITNAME docker://$REFNAME
+ ${PODMAN_BUILD} -t ${COMMITNAME} -f ${DOCKERFILE} .
+ podman push ${COMMITNAME}
+ skopeo copy --dest-creds ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} \
+ docker://${COMMITNAME} docker://${REFNAME}
else
- echo "unknown build type $TYPE"
+ echo "unknown build type ${TYPE}"
exit 1
fi
--
2.39.2
More information about the igt-dev
mailing list