Make decision wheter to build images in CI or not

Instead of using canusecache function, make a script that could
be used by quickstart to determine quickly if we need to build
image or download ready from mirror server.
Usages:
    - bash: if $(to_build); then ...
    - ansible: when: {{ lookup('pipe', 'path/to/to_build')|bool }}

Change-Id: Id5aefcf588ef984be6de07e4c7e76b5a4c5e93ad
This commit is contained in:
Sagi Shnaidman 2017-03-06 19:26:41 +02:00
parent cf5e1d2f6c
commit 2b18e6617c

18
scripts/to_build Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
function set_env {
export TO_BUILD=$1
echo $TO_BUILD
exit
}
# If we are uploading to the cache then we shouldn't use it
[[ "$CACHEUPLOAD" == 1 ]] && set_env "true"
# The updates job already takes a long time, always use cache for it
[[ "$TOCI_JOBTYPE" =~ updates ]] && set_env "false"
# There are some projects that require images building
for PROJFULLREF in ${ZUUL_CHANGES//^/ };
do
PROJ=${PROJFULLREF%%:*};
PROJ=${PROJ##*/};
[[ "$PROJ" =~ diskimage-builder|tripleo-image-elements|tripleo-puppet-elements|instack-undercloud|python-tripleoclient|tripleo-common ]] && set_env "true"
done
set_env "false"