2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
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 ##############################################################################
12 echo "---> docker-get-container-tag.sh"
14 # Gets the container tag per $CONTAINER_TAG_METHOD
15 # For YAML file use directory $CONTAINER_TAG_YAML_DIR
16 # if a value is provided, else fall back to $DOCKER_ROOT
17 # use login flag to get $HOME/.local/bin in PATH
22 if [[ $CONTAINER_TAG_METHOD == "latest" ]]; then
24 elif [[ $CONTAINER_TAG_METHOD == "stream" ]]; then
26 elif [[ $CONTAINER_TAG_METHOD == "git-describe" ]]; then
28 elif [[ $CONTAINER_TAG_METHOD == "yaml-file" ]]; then
29 dir=${CONTAINER_TAG_YAML_DIR:-$DOCKER_ROOT}
30 tag_file=$dir/container-tag.yaml
31 if [[ -f $tag_file ]]; then
32 # pip installs yq to $HOME/.local/bin
33 tag=$(yq -r .tag "$tag_file")
35 echo "File $tag_file not found."
38 echo "Method $CONTAINER_TAG_METHOD not implemented (yet)"
40 if [[ -z $tag ]]; then
41 echo "Failed to get a container tag using method $CONTAINER_TAG_METHOD"
44 echo "---> Docker image tag found: $tag"
45 # Write DOCKER_IMAGE_TAG information to a file so it can be
46 # injected into the environment for following steps
47 echo "DOCKER_IMAGE_TAG=$tag" >> "$WORKSPACE/env_docker_inject.txt"