Updated trigger.sh to output env and solution variables prior to firing trigger
Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
parent
7d3c964541
commit
07ac31c5dd
@ -3,14 +3,34 @@
|
||||
# 1. List project triggers, looking for 'sys_osgc CI trigger'
|
||||
# 2. If not found, create the 'sys_osgc CI trigger'
|
||||
# 3. Invoke the trigger
|
||||
#
|
||||
# The trigger will pass in the following variables (declared from
|
||||
# the environment or from the SOLUTION file)
|
||||
#
|
||||
|
||||
TRIGGER_VARS=(
|
||||
OS_DISTRO
|
||||
OS_RELEASE
|
||||
PACKAGE_STREAM
|
||||
PACKAGE_REPOSITORY
|
||||
BRANCH
|
||||
BUILD
|
||||
REF
|
||||
)
|
||||
|
||||
# Create a copy of the current values for each trigger
|
||||
# variable so we can show which ones were modified by the
|
||||
# SOLUTION import.
|
||||
for variable in ${TRIGGER_VARS[@]}; do
|
||||
def=def_${variable}
|
||||
export ${def}="${!variable}"
|
||||
done
|
||||
|
||||
# Bring in the variables from SOLUTION file, supporting
|
||||
# nested substitution
|
||||
. SOLUTION
|
||||
. MANIFEST
|
||||
|
||||
VARS=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION))
|
||||
VARS+=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST))
|
||||
for var in ${VARS[@]}; do
|
||||
export ${var}
|
||||
done
|
||||
@ -110,22 +130,19 @@ TOKEN=$(echo ${RESULTS} | sed -E 's#([[{},])#\1\n#g' | {
|
||||
echo "Using token: ${TOKEN}"
|
||||
|
||||
function post {
|
||||
RESULTS=$(curl --noproxy '*' -s -X POST \
|
||||
-F "token=${TOKEN}" \
|
||||
-F "ref=${REF}" \
|
||||
-F "variables[OS_DISTRO]=${OS_DISTRO}" \
|
||||
-F "variables[OS_RELEASE]=${OS_RELEASE}" \
|
||||
-F "variables[PACKAGE_STREAM]=${PACKAGE_STREAM}" \
|
||||
-F "variables[PACKAGE_REPOSITORY]=${PACKAGE_REPOSITORY}" \
|
||||
-F "variables[BRANCH]=${BRANCH}" \
|
||||
-F "variables[BUILD]=${BUILD}" \
|
||||
-F "variables[BUILDNUMBER]=${BUILD}" \
|
||||
${GITLAB}/api/v4/projects/${URI_PROJECT}/trigger/pipeline)
|
||||
CMD="curl --noproxy '*' -s -X POST -F token=${TOKEN} -F ref=${REF} "
|
||||
for variable in ${TRIGGER_VARS[@]}; do
|
||||
CMD+="-F variables[${variable}]=${!variable} "
|
||||
done
|
||||
CMD+="${GITLAB}/api/v4/projects/${URI_PROJECT}/trigger/pipeline"
|
||||
|
||||
RESULTS=$(${CMD})
|
||||
|
||||
PIPELINE=$(echo ${RESULTS} | sed -nE 's,^.*details_path":"([^"]*)".*,\1,p')
|
||||
|
||||
[[ "${PIPELINE}" == "" ]] && {
|
||||
>&2 echo "Unable to find pipeline details URL"
|
||||
>&2 echo "Unable to find pipeline details URL when running:"
|
||||
>&2 echo "${CMD}"
|
||||
>&2 echo ${RESULTS}
|
||||
return 1
|
||||
}
|
||||
@ -134,8 +151,35 @@ function post {
|
||||
true
|
||||
}
|
||||
|
||||
echo "Triggering pipeline on project ${PROJECT} for BUILD=${BUILD} and BRANCH=${BRANCH}"
|
||||
while read -n1 -r -p "Is this correct [y|N]?"; do
|
||||
cat << EOF
|
||||
Triggering pipeline on project:
|
||||
|
||||
${PROJECT}
|
||||
|
||||
With the following variables:
|
||||
|
||||
$(
|
||||
has_override=0
|
||||
for variable in ${TRIGGER_VARS[@]}; do
|
||||
def=def_${variable}
|
||||
modified=' '
|
||||
if [[ "${!def}" != "" ]]; then
|
||||
if [[ "${!def}" != "${!variable}" ]]; then
|
||||
modified='*'
|
||||
has_override=1
|
||||
fi
|
||||
fi
|
||||
echo " ${modified} ${variable}=${!variable}"
|
||||
done
|
||||
|
||||
(( has_override )) && {
|
||||
echo -e " ^\n │\n └── Value set in ENV but modified by SOLUTION file."
|
||||
}
|
||||
)
|
||||
|
||||
EOF
|
||||
|
||||
while read -n1 -r -p "Is this correct [y|N]? "; do
|
||||
case $REPLY in
|
||||
y|Y)
|
||||
echo ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user