Retries a failed OR timed_out OR a job whose step has the manual retry after passing attribute set to true (that is, permit_on_passed: true). You can only retry each job.id once. To retry a “second time” use the new job.id returned in the first retry query.
I am running under the constraint that the system only gets the URL at the time when the first job gets submitted (before any retries). Is there another URL I can hit (like some sort of job family url) that can trigger a retry without having to know the very latest job that ran?
Hi and thanks for reaching out to Buildkite Support ,
So, there isn’t a “job family” or step-level retry endpoint that automatically finds and retries the latest instance of a job. The retry endpoints (both REST and GraphQL) require the specific job ID, and as you noted, each job can only be retried once before you need the new job ID.
However, you can work around this constraint by querying the build to find the latest job for your step before triggering the retry. Here are both approaches with working curl examples:
REST API Approach:
# Step 1: Get all jobs in the build
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"https://api.buildkite.com/v2/organizations/org-slug/pipelines/pipeline-slug/builds/BUILD_NUM/jobs"
# Step 2: Find the job with your step_key that hasn't been retried
JOB_ID=$(curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"https://api.buildkite.com/v2/organizations/org-slug/pipelines/pipeline-slug/builds/BUILD_NUM/jobs" \
| jq -r '.[] | select(.step_key == "your-step-key" and .retried == false) | .id' \
| head -1)
# Step 3: Retry that specific job
curl -X PUT \
-H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"https://api.buildkite.com/v2/organizations/org-slug/pipelines/pipeline-slug/builds/BUILD_NUM/jobs/${JOB_ID}/retry"