Skip to content
Snippets Groups Projects
Commit 2c653c8c authored by jurgenhaas's avatar jurgenhaas
Browse files

Improve debugging output

Provide argument from which branch to download
parent 87897e59
No related branches found
No related tags found
1 merge request!18Merging develop into main
......@@ -7,7 +7,7 @@ in
*) echo "Provide either db or files as a first argument!"
exit 1;;
esac
branch=main
branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "x$2" != "x" ]]; then
branch=$2
fi
......@@ -23,12 +23,17 @@ function gitlab() {
echo curl --write-out "\nHTTP-Code:%{http_code}" -X "$METHOD" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$REQUEST" "$@"
fi
output="$(curl --write-out "\nHTTP-Code:%{http_code}" -X "$METHOD" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$REQUEST" "$@")"
if [[ "${DEBUG}" == "yes" ]]; then
echo $output
fi
result="$(echo "$output" | grep "{")"
code="$(echo "$output" | grep -m 1 "HTTP-Code:" | cut -d: -f2)"
if [[ $code -eq $EXPECTED ]]; then
return
fi
echo $output
if [[ "${DEBUG}" == "no" ]]; then
echo $output
fi
echo "$METHOD request to $REQUEST did not succeed! Responds with code $code instead of $EXPECTED"
exit 99
}
......@@ -106,7 +111,7 @@ if [[ "a${TRIGGERTOKEN}a" == "aa" ]]; then
fi
echo "Trigger pipeline ..."
gitlab 201 POST projects/"$PRJID"/trigger/pipeline --data "token=$TRIGGERTOKEN" --data "ref=${branch}" --data "variables[TRIGGERTASK]=$mode"
gitlab 201 POST projects/"$PRJID"/trigger/pipeline --data "token=$TRIGGERTOKEN" --data "ref=${branch}" --data "variables[TRIGGERTASK]=$mode" --data "variables[TRIGGER_INPUT]=$branch"
PIPELINEID=$(echo "$result" | jq -r ."id")
PIPELINESTATUS=$(echo "$result" | jq -r ."status")
......
#!/bin/bash
export DEBUG=no
function gitlab() {
EXPECTED=$1
METHOD=$2
......@@ -9,11 +11,17 @@ function gitlab() {
echo curl --write-out "\nHTTP-Code:%{http_code}" -X "$METHOD" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$REQUEST" "$@"
fi
output="$(curl --write-out "\nHTTP-Code:%{http_code}" -X "$METHOD" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$REQUEST" "$@")"
if [[ "${DEBUG}" == "yes" ]]; then
echo $output
fi
result="$(echo "$output" | grep "{")"
code="$(echo "$output" | grep -m 1 "HTTP-Code:" | cut -d: -f2)"
if [[ $code -eq $EXPECTED ]]; then
return
fi
if [[ "${DEBUG}" == "no" ]]; then
echo $output
fi
echo "$METHOD request to $REQUEST did not succeed! Responds with code $code instead of $EXPECTED"
exit 99
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment