Jobs
A collection of common tasks with jobs using the GraphQL API.
You can test out the Buildkite GraphQL API using the Buildkite GraphQL console. This includes built-in documentation under its Documentation tab.
Get all jobs in a given queue for a given timeframe
Get jobs in a named queue, created at or after createdAtFrom (inclusive) and before createdAtTo (exclusive), using organization.jobs. Both arguments accept DateTime values in ISO-8601 UTC format. Omit either argument to leave that end of the timeframe unrestricted.
The following query returns the first 100 matching jobs created on October 1, 2026, UTC. To search across all queues in your Buildkite organization, omit agentQueryRules.
Matching multiple agent query rules
When you pass more than one value in agentQueryRules, a job must match all of them. The agentQueryRules argument combines multiple values with AND, not OR. For example, agentQueryRules: ["queue=test", "tag=value"] returns only jobs whose agent query rules include both queue=test and tag=value.
query JobsInQueueForTimeframe($after: String) {
organization(slug: "organization-slug") {
jobs(
first: 100
after: $after
agentQueryRules: ["queue=queue-name"]
createdAtFrom: "2026-10-01T00:00:00Z"
createdAtTo: "2026-10-02T00:00:00Z"
) {
edges {
node {
... on JobTypeCommand {
uuid
agentQueryRules
createdAt
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
When pageInfo.hasNextPage is true, pass pageInfo.endCursor as the after variable in the next request. Repeat until hasNextPage is false to retrieve all matching jobs.
Get all jobs in a particular concurrency group
To see which jobs are waiting for a concurrency group in case the secret URL fails, you can use the following query.
query getConcurrency {
organization(slug: "organization-slug") {
jobs(first:100,concurrency:{group:"name"}, type:[COMMAND], state:[LIMITED,WAITING,ASSIGNED]) {
edges {
node {
... on JobTypeCommand {
url
createdAt
}
}
}
}
}
}
Handling 504 errors
When attempting to get all jobs in a particular concurrency group throughout your Buildkite organization, you might receive a 504 error in the response, which could result from your specific query being too resource-intensive for the Buildkite GraphQL API to resolve. In such circumstances, restrict the query by a specific pipeline, using its slug.
query getConcurrency {
organization(slug: "organization-slug/pipeline-slug") {
jobs(first:100,concurrency:{group:"name"}, type:[COMMAND], state:[LIMITED,WAITING,ASSIGNED]) {
edges {
node {
... on JobTypeCommand {
url
createdAt
}
}
}
}
}
}
Get the last job of an agent
To get the last job of an agent or null. You will need to know the UUID of the agent.
query AgentJobs {
agent(slug: "organization-slug/agent-UUID") {
jobs(first: 10) {
edges {
node {
... on JobTypeCommand {
state
build {
state
}
}
}
}
}
}
}
Get the job run time per build
To get the run time of each job in a build, you can use the following query.
query GetJobRunTimeByBuild {
build(slug: "organization-slug/pipeline-slug/build-number") {
jobs(first: 1) {
edges {
node {
... on JobTypeCommand {
startedAt
finishedAt
}
}
}
}
}
}
Get a job's UUID
To get UUIDs of the jobs in a build, you can use the following query.
query GetJobsUUID {
build(slug: "org-slug/pipeline-slug/build-number") {
jobs(first: 1) {
edges {
node {
... on JobTypeCommand {
uuid
}
}
}
}
}
}
Get info about a job by its UUID
Get info about a job using the job's UUID only.
query GetJob {
job(uuid: "a00000a-xxxx-xxxx-xxxx-a000000000a") {
... on JobTypeCommand {
id
uuid
createdAt
scheduledAt
finishedAt
pipeline{
name
}
build{
id
number
pipeline{
name
}
}
}
}
}
Cancel a job
If you need to cancel a job, you can use the following call with the job's ID:
mutation CancelJob {
jobTypeCommandCancel(input: { id: "job-id" }) {
jobTypeCommand {
id
}
}
}
Get retry information for a job
Gets information about how a job was retried (retryType), who retried the job (retriedBy) and which job was source of the retry (uuid).
retriedBy will be null if the retryType is AUTOMATIC.
query GetJobRetryInformation {
job(uuid: "job-uuid") {
... on JobTypeCommand {
retrySource {
... on JobInterface {
uuid
retried
retryType
retriedBy {
email
name
}
}
}
}
}
}