25 lines
763 B
Bash
25 lines
763 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Lancer une pipeline
|
||
|
request=$(curl --silent --request POST --header "Authorization: Bearer ${DRONE_TOKEN}" ${DRONE_BASE_URL}/api/repos/${DRONE_REPOSITORY_PATH}/builds${DRONE_URL_PARAM} | jq .number)
|
||
|
|
||
|
# Attendre que la pipeline ne soit plus en exécution
|
||
|
while true; do
|
||
|
# Récupérer l'état de la pipeline
|
||
|
status=$(curl --silent --request GET --header "Authorization: Bearer ${DRONE_TOKEN}" ${DRONE_BASE_URL}/api/repos/${DRONE_REPOSITORY_PATH}/builds/$request | jq .status)
|
||
|
|
||
|
case "${status}" in
|
||
|
"\"pending\"" | "\"running\"")
|
||
|
sleep 5s
|
||
|
;;
|
||
|
"\"success\"")
|
||
|
echo "${DRONE_REPOSITORY_PATH}: ${status}"
|
||
|
exit 0
|
||
|
;;
|
||
|
*)
|
||
|
echo "${DRONE_REPOSITORY_PATH}: ${status}"
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
done
|