role_drone_runner_exec/files/drone-downstream.bash

25 lines
763 B
Bash
Raw Normal View History

2022-10-17 11:06:34 +00:00
#!/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