summaryrefslogtreecommitdiffstats
path: root/ansible/docker/build_ansible_image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/docker/build_ansible_image.sh')
-rwxr-xr-xansible/docker/build_ansible_image.sh10
1 files changed, 4 insertions, 6 deletions
diff --git a/ansible/docker/build_ansible_image.sh b/ansible/docker/build_ansible_image.sh
index d54ddc43..49833be5 100755
--- a/ansible/docker/build_ansible_image.sh
+++ b/ansible/docker/build_ansible_image.sh
@@ -27,14 +27,12 @@ image_name="${2:-ansible:latest}"
script_path=$(readlink -f "$0")
script_dir=$(dirname "$script_path")
-git_commit=$(git rev-parse --revs-only HEAD)
+git_commit=$(git rev-parse --revs-only HEAD || true)
build_date=$(date -I)
-if [ -z "$ansible_version" ]; then
- docker build "$script_dir" -t "${image_name}" --label "git-commit=$git_commit" --label "build-date=$build_date"
-else
- docker build "$script_dir" -t "${image_name}" --label "git-commit=$git_commit" --label "build-date=$build_date" --build-arg ansible_version="$ansible_version"
-fi
+docker build "$script_dir" -t "${image_name}" --label "build-date=$build_date" \
+ ${git_commit:+--label git-commit=${git_commit}} \
+ ${ansible_version:+--build-arg ansible_version=${ansible_version}}
# Export docker image into chroot and tararchive it. It takes ~40M of space and is packaged together with sw.
if "${script_dir}"/create_docker_chroot.sh convert "${image_name}" "${script_dir}"/ansible_chroot ; then