@@ -14,7 +14,7 @@ BRANCH="${TRAVIS_BRANCH:-`git rev-parse --abbrev-ref HEAD | tr / -`}"
14
14
echo Branch: $BRANCH
15
15
16
16
# ...same for the commit.
17
- COMMIT=" ${TRAVIS_COMMIT :- `git rev-parse HEAD`} "
17
+ COMMIT=` git rev-parse --short HEAD`
18
18
echo Commit: $COMMIT
19
19
20
20
# Version is extracted from project.clj so that a meaningful tag can
32
32
exit 1
33
33
fi
34
34
35
+ # Including the short commit SHA ensures uniquely identified builds
36
+ # as its possible for users to commit changes without incrementing
37
+ # version numbers, resulting new builds with the same tag
38
+ BRANCH_TAG=$REPO :$BRANCH -$VERSION -$COMMIT
39
+ echo " BRANCH_TAG: ${BRANCH_TAG} "
40
+
35
41
# Travis will build topic branches, but Docker images should not be
36
42
# built for each one because this would result in a *lot* of images
37
43
# during periods of active development.
38
44
if [ " $BRANCH " == " master" ] || [ " $BRANCH " == " develop" ] ; then
39
45
40
- # Using the commit SHA will ensure that built images persist on
41
- # Docker Hub unless explicitly removed. A more meaningful tag
42
- # is also created using the <branch>-<version> but that can be
43
- # superseded by subsequent builds.
44
- COMMIT_TAG=$REPO :$COMMIT
45
- BRANCH_TAG=$REPO :$BRANCH -$VERSION
46
-
47
46
echo " Building Docker image for $COMMIT_TAG ($BRANCH_TAG )"
48
47
lein uberjar
49
- docker build -f Dockerfile -t $COMMIT_TAG .
50
- docker tag $COMMIT_TAG $BRANCH_TAG
48
+ docker build -f Dockerfile -t $BRANCH_TAG .
51
49
docker push $REPO
52
50
echo " Building Docker image ... done"
53
51
0 commit comments