Created
September 7, 2020 10:36
-
-
Save meriororen/230248b3bb4a8548bdaac3b305f168d3 to your computer and use it in GitHub Desktop.
Force retry last job in gitlab projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
all_project_ids=`curl -s --header "PRIVATE-TOKEN: ${gitlab_access}" \ | |
"https://gitlab.com/api/v4/projects?membership=true&simple=true&per_page=100" | jq '.[] | select(.path_with_namespace|test("'${filter}'")) | .id'` | |
echo $all_project_ids | |
for i in $all_project_ids; do | |
last_job=`curl -s --globoff --header "PRIVATE-TOKEN: ${gitlab_access}" "https://gitlab.com/api/v4/projects/${i}/jobs" | jq '.[0] | select(.id != null) | .id'` | |
if [ "$last_job" != "" ]; then | |
echo "retrying job id: $last_job" | |
curl -s --request POST --header "PRIVATE-TOKEN: ${gitlab_access}" "https://gitlab.com/api/v4/projects/${i}/jobs/${last_job}/retry" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment