936c272f3e17d5fdf0ffeb7e9a6e2045393ea6ed
[releng/global-jjb.git] / shell / docker-get-yaml-tag.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-yaml-tag.sh"
12 # Gets the container tag from a yaml file.
13
14 set -eu -o pipefail
15
16 # Install yq to read container-tag.yaml
17 python -m pip install --user --quiet --upgrade yq
18 export PATH="/home/jenkins/.local/bin:$PATH"
19
20 cd "$DOCKER_ROOT"
21 container_tag_file=container-tag.yaml
22
23 if [ -f "$container_tag_file" ]
24 then
25     image_name=$(yq -r .tag "$container_tag_file")
26 else
27     echo "$container_tag_file file not found. Make sure this file exists."
28     exit 1
29 fi
30
31 # Write DOCKER_IMAGE information to a file so it can be injected into the
32 # environment for following steps
33 echo "DOCKER_IMAGE=$image_name" >> "$WORKSPACE/env_docker_inject.txt"