Skip to content

Commit

Permalink
travis-ci.sh: Print an error if TRAVIS_BRANCH, DOCKER_PASSWORD, or DO…
Browse files Browse the repository at this point in the history
…CKER_LOGIN is undefined or empty.
  • Loading branch information
octo committed Sep 1, 2020
1 parent f47b7e6 commit 5ad9214
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions travis-ci.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/bin/sh -e
#!/bin/bash

if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
set -ex

if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
echo "Not building docker images out of Pull Requests"
exit 0
fi

if [ ! -z "${TRAVIS_BRANCH}" ]; then
SLUG="collectd/ci:${TRAVIS_BRANCH}"
docker build --pull -t "${SLUG}" .
docker inspect "${SLUG}"
docker history "${SLUG}"
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_LOGIN}" --password-stdin
docker push "${SLUG}"
else
echo 'no $TRAVIS_BRANCH defined, exiting'
exit 1
fi
declare -r SLUG="collectd/ci:${TRAVIS_BRANCH:?}"
docker build --pull -t "${SLUG}" .
docker inspect "${SLUG}"
docker history "${SLUG}"
echo "${DOCKER_PASSWORD:?}" | docker login --username "${DOCKER_LOGIN:?}" --password-stdin
docker push "${SLUG}"

0 comments on commit 5ad9214

Please sign in to comment.