summaryrefslogtreecommitdiff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-09-02 10:33:20 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-09-03 18:26:50 +0300
commitdc2ba64f8965f8e7db5db49b8260dbfc5834faa5 (patch)
tree46a75ce4958f1f51e3d30a4718c085fae528d134 /.gitlab-ci
parent88666330f5c93cb740ed668c837c7a797f3f47fc (diff)
.gitalb-ci: Use only the necessary tags
Tag build-* images only with dockerfile-$FILE_SHA1 for changes detection and commit-$COMMIT_SHA1, so we know which set of images we have to use for any given commit. The igt container needs only ref (e.g. master) and commit-$COMMIT_SHA1 tags, as the dockerfile-$FILE_SHA1 one is irrelevant - we build build every time anyway. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x.gitlab-ci/pull-or-rebuild.sh47
1 files changed, 29 insertions, 18 deletions
diff --git a/.gitlab-ci/pull-or-rebuild.sh b/.gitlab-ci/pull-or-rebuild.sh
index 7e69477e..3f00e831 100755
--- a/.gitlab-ci/pull-or-rebuild.sh
+++ b/.gitlab-ci/pull-or-rebuild.sh
@@ -21,9 +21,10 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-DOCKERFILE=$1
-NAME=$2
-REF=${3:-${CI_COMMIT_REF_NAME:-latest}}
+TYPE=$1
+DOCKERFILE=$2
+NAME=$3
+REF=${4:-${CI_COMMIT_REF_NAME:-latest}}
REF=$(echo $REF | tr / - )
IMAGENAME=$CI_REGISTRY/$CI_PROJECT_PATH/$NAME
@@ -33,21 +34,31 @@ REFNAME=$IMAGENAME:$REF
DOCKERNAME=$IMAGENAME:dockerfile-$DOCKERFILE_CHECKSUM
COMMITNAME=$IMAGENAME:commit-$CI_COMMIT_SHA
-docker pull $DOCKERNAME
-IMAGE_PRESENT=$?
+if [ "$TYPE" = "base" ]; then
+ # base container (building, etc) - we rebuild only if changed or forced
+ docker pull $DOCKERNAME
+ IMAGE_PRESENT=$?
-set -e
-if [ $IMAGE_PRESENT -eq 0 ] && [ ${FORCE_REBUILD:-0} -eq 0 ] ; then
- echo "Skipping, already built"
- docker tag $DOCKERNAME $NAME
- docker tag $DOCKERNAME $REFNAME
- docker tag $DOCKERNAME $COMMITNAME
-else
- echo "Building!"
+ set -e
+ if [ $IMAGE_PRESENT -eq 0 ] && [ ${FORCE_REBUILD:-0} -eq 0 ] ; then
+ echo "Skipping, already built"
+ docker tag $DOCKERNAME $COMMITNAME
+ else
+ echo "Building!"
+ docker build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA \
+ -t $DOCKERNAME -t $COMMITNAME -f $DOCKERFILE .
+ docker push $DOCKERNAME
+ fi
+ docker push $COMMITNAME
+elif [ "$TYPE" = "igt" ]; then
+ # container with IGT, we don't care about Dockerfile changes
+ # we always rebuild
+ set -e
docker build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA \
- -t $DOCKERNAME -t $NAME \
- -t $REFNAME -t $COMMITNAME -f $DOCKERFILE .
- docker push $DOCKERNAME
+ -t $REFNAME -t $COMMITNAME -f $DOCKERFILE .
+ docker push $REFNAME
+ docker push $COMMITNAME
+else
+ echo "unknown build type $TYPE"
+ exit 1
fi
-docker push $REFNAME
-docker push $COMMITNAME