c1a3d21e06d2302638dea0e242f8ea288be0401c
[releng/global-jjb.git] / shell / docker-get-git-describe.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> docker-get-git-describe.sh"
12 # Gets the container tag using git describe.
13
14 set -eu -o pipefail
15
16 cd "$DOCKER_ROOT"
17
18 image_build_tag=$(git describe)
19
20 if [ -z "$image_build_tag" ]
21 then
22     echo "git describe returned an empty value, make sure a version tag is applied"
23     exit 1
24 fi
25 echo "---> Tag found: $image_build_tag"
26 # Write DOCKER_IMAGE_TAG information to a file so it can be injected into the
27 # environment for following steps
28 echo "DOCKER_IMAGE_TAG=$image_build_tag" >> "$WORKSPACE/env_docker_inject.txt"