Skip to content
This repository was archived by the owner on Feb 29, 2020. It is now read-only.

Commit 7cd7231

Browse files
authored
Merge pull request #12 from USGS-EROS/jira/lcmap-1714
updated build to include git short hash
2 parents c0309d3 + 704f5d6 commit 7cd7231

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

bin/build

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ BRANCH="${TRAVIS_BRANCH:-`git rev-parse --abbrev-ref HEAD | tr / -`}"
1414
echo Branch: $BRANCH
1515

1616
# ...same for the commit.
17-
COMMIT="${TRAVIS_COMMIT:-`git rev-parse HEAD`}"
17+
COMMIT=`git rev-parse --short HEAD`
1818
echo Commit: $COMMIT
1919

2020
# Version is extracted from project.clj so that a meaningful tag can
@@ -32,22 +32,20 @@ else
3232
exit 1
3333
fi
3434

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+
3541
# Travis will build topic branches, but Docker images should not be
3642
# built for each one because this would result in a *lot* of images
3743
# during periods of active development.
3844
if [ "$BRANCH" == "master" ] || [ "$BRANCH" == "develop" ] ; then
3945

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-
4746
echo "Building Docker image for $COMMIT_TAG ($BRANCH_TAG)"
4847
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 .
5149
docker push $REPO
5250
echo "Building Docker image ... done"
5351

0 commit comments

Comments
 (0)