Skip to content

Instantly share code, notes, and snippets.

@meriororen
Created September 7, 2020 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meriororen/230248b3bb4a8548bdaac3b305f168d3 to your computer and use it in GitHub Desktop.
Save meriororen/230248b3bb4a8548bdaac3b305f168d3 to your computer and use it in GitHub Desktop.
Force retry last job in gitlab projects
#!/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