Skip to content
Snippets Groups Projects
Commit 6c79bca9 authored by jurgenhaas's avatar jurgenhaas
Browse files
parent 69a50936
No related branches found
No related tags found
1 merge request!6Merging develop into main
#!/bin/bash
function gitlab() {
EXPECTED=$1
METHOD=$2
REQUEST=$3
shift 3
echo " sending request ..."
output="$(curl --write-out "\nHTTP-Code:%{http_code}" -X "$2" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$3" "$@")"
output="$(curl --write-out "\nHTTP-Code:%{http_code}" -X "$METHOD" -s -H "Private-Token: ${GITLAB_PRIVATE_TOKEN}" "${GITLAB_URL}"/api/v4/"$REQUEST" "$@")"
echo " done"
result="$(echo "$output" | grep "{")"
code="$(echo "$output" | grep -m 1 "HTTP-Code:" | cut -d: -f2)"
if [[ $code -eq $1 ]]; then
if [[ $code -eq $EXPECTED ]]; then
return
fi
echo "$2 request to $3 did not succeed! Responds with code $code instead of $1"
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