Created
March 24, 2026 18:46
-
-
Save vctls/c217208d7922d81662736efce533273e to your computer and use it in GitHub Desktop.
Infinite Gitlab CI job retries
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
| stages: | |
| - test | |
| - retry | |
| test: | |
| stage: test | |
| script: | |
| - ... | |
| after_script: | |
| - | | |
| if [ $CI_JOB_STATUS != 'success' ]; then | |
| curl -s --header "PRIVATE-TOKEN: ${CI_TOKEN}" \ | |
| "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" \ | |
| | jq '.[] | select(.name == "retry") | .id' \ | |
| | xargs -I {} curl -s --header "PRIVATE-TOKEN: ${CI_TOKEN}" -X POST \ | |
| "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/{}/retry" | |
| fi | |
| retry: | |
| stage: retry | |
| when: on_failure | |
| script: | |
| - | | |
| curl -s --header "PRIVATE-TOKEN: ${CI_TOKEN}" \ | |
| "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" \ | |
| | jq '.[] | select(.name == "test") | .id' \ | |
| | xargs -I {} curl -s --header "PRIVATE-TOKEN: ${CI_TOKEN}" -X POST \ | |
| "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/{}/retry" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Gitlab CI configuration to work around the retry count limit of Gitlab and retry jobs indefinitely until success or pipeline duration limit.