Fix: Use lf-activate-venv to install openstack dep
[releng/builder.git] / jjb / opendaylight-infra-update-image-list.sh
1 #!/bin/sh -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='
36 '
37 # We purposely want globbing here to build images list
38 # shellcheck disable=SC2207
39 IMAGES="$(openstack image list --long -f value -c Name -c Protected \
40     | grep 'ZZCI.*True' | sed 's/ True//')"
41 for i in $IMAGES; do
42     echo "Adding image $i"
43     echo "* $i" >> "$WORKSPACE/docs/cloud-images.rst"
44 done
45
46 git add docs/cloud-images.rst