c7ac71731cd2ac10abf868a035c16e896a2ed03c
[releng/builder.git] / jjb / opendaylight-infra-update-image-list.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 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
12 set -e -o pipefail
13
14 # shellcheck disable=SC1090
15 . ~/lf-env.sh
16
17 # Check if openstack venv was previously created
18 if [ -f "/tmp/.os_lf_venv" ]; then
19     os_lf_venv=$(cat "/tmp/.os_lf_venv")
20 fi
21
22 if [ -d "${os_lf_venv}" ] && [ -f "${os_lf_venv}/bin/openstack" ]; then
23     echo "Re-use existing venv: ${os_lf_venv}"
24     PATH=$os_lf_venv/bin:$PATH
25 else
26     lf-activate-venv --python python3 python-openstackclient
27 fi
28
29 cat > "$WORKSPACE/docs/cloud-images.rst" << EOF
30 Following are the list of published images available to Jenkins jobs.
31
32 EOF
33 # Blank line before EOF is on purpose to ensure there is spacing.
34
35 IFS=$'\n'
36 # We purposely want globbing here to build images list
37 # shellcheck disable=SC2207
38 IMAGES=($(openstack image list --long -f value -c Name -c Protected \
39     | grep 'ZZCI.*True' | sed 's/ True//'))
40 for i in "${IMAGES[@]}"; do
41     echo "Adding image $i"
42     echo "* $i" >> "$WORKSPACE/docs/cloud-images.rst"
43 done
44
45 git add docs/cloud-images.rst