Use this API to run CI/CD jobs on a runner: request the next job, update its state, append to its log, and transfer its artifacts.
GitLab Runner uses these endpoints itself.
Request a job
POST /api/v4/jobs/request
Requests a job for a runner to execute.
Request body (application/json)
| Property | Type | Description |
|---|---|---|
info | Object | Runner’s metadata |
info. | String | Runner’s architecture |
info. | Object | Runner’s config |
info. | String | GPUs enabled |
info. | String | Runner’s executor |
info. | Object | Runner’s features |
info. | Object | Runner’s labels |
info. | String | Runner’s name |
info. | String | Runner’s platform |
info. | String | Runner’s revision |
info. | String | Runner’s version |
last_ | String | last_ token of the runner queue |
session | Object | Session data of the runner |
session. | String | Authorization of the session |
session. | String | Certificate of the session |
session. | String | URL of the session |
system_ | String | Runner’s system identifier |
tokenRequired | String | Runner’s authentication token |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Job was scheduled | APIEntities |
204 | No job for Runner | — |
400 | Bad Request | — |
403 | Forbidden | — |
409 | Conflict | — |
422 | Runner is orphaned | — |
429 | Too Many Requests | — |
Update a job
PUT /api/v4/jobs/{id}
Updates the state and other attributes of a job. Used by runners while executing a job.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
checksum | String | CRC32 checksum of the job trace |
exit_ | Integer | Exit code of the job |
failure_ | String | Failure reason of the job |
output | Object | Build log state |
output. | Integer | Size of the job’s trace output, |
output. | String | CRC32 checksum of the job trace |
runtime_ | String | Runtime environment key emitted by the runner on job suspension Maximum length: 512 |
state | String | Status of the job:running,success,failed |
tokenRequired | String | Authentication token of the job |
Responses
| Code | Description | Schema |
|---|---|---|
200 | Job was updated | — |
202 | Update accepted | — |
400 | Unknown parameters | — |
403 | Forbidden | — |
404 | Not Found | — |
409 | Conflict | — |
429 | Too Many Requests | — |
Download job artifacts
GET /api/v4/jobs/{id}/artifacts
Downloads artifacts for a specified job.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
tokenQuery | String | Authentication token of the job |
direct_Query | Boolean | If true,Default: false |
download_Query | String | Requested download transfer mode (proxy or direct).Allowed values: proxy,direct |
Responses
| Code | Description | Schema |
|---|---|---|
200 | Download allowed | String (binary) (application/) |
302 | Found | String (binary) (application/) |
400 | Bad Request | — |
401 | Unauthorized | — |
403 | Forbidden | — |
404 | Artifact not found | — |
429 | Too Many Requests | — |
Upload job artifacts
POST /api/v4/jobs/{id}/artifacts
Uploads artifacts for a specified job.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
Request body (multipart/form-data)
| Property | Type | Description |
|---|---|---|
accessibility | String | Specify accessibility level of artifact private/ |
artifact_ | String | The format of artifact Allowed values: raw,zip,gzipDefault: zip |
artifact_ | String | Type of artifact Allowed values: archive,metadata,trace,junit,sast,dependency_,container_,dast,codequality,license_,performance,metrics,metrics_,network_,lsif,dotenv,cobertura,terraform,accessibility,cluster_,secret_,requirements,coverage_,browser_,load_,api_,cluster_,cyclonedx,requirements_,annotations,repository_,jacoco,sarifDefault: archive |
expire_ | String | Specify when artifact should expire |
fileRequired | String (binary) | The artifact file to store (generated by Multipart middleware) |
metadata | String (binary) | The artifact metadata to store (generated by Multipart middleware) |
token | String | Authentication token of the job |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | — |
400 | Bad request | — |
403 | Forbidden | — |
404 | Not Found | — |
405 | Artifacts support not enabled | — |
413 | File too large | — |
429 | Too Many Requests | — |
Authorize artifacts upload
POST /api/v4/jobs/{id}/artifacts/authorize
Authorizes uploading artifacts for a specified job.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
artifact_ | String | Type of artifact Allowed values: archive,metadata,trace,junit,sast,dependency_,container_,dast,codequality,license_,performance,metrics,metrics_,network_,lsif,dotenv,cobertura,terraform,accessibility,cluster_,secret_,requirements,coverage_,browser_,load_,api_,cluster_,cyclonedx,requirements_,annotations,repository_,jacoco,sarifDefault: archive |
filesize | Integer | Size of the artifact file |
token | String | Authentication token of the job |
Responses
| Code | Description | Schema |
|---|---|---|
200 | Upload allowed | — |
400 | Bad Request | — |
403 | Forbidden | — |
404 | Not Found | — |
405 | Artifacts support not enabled | — |
413 | File too large | — |
429 | Too Many Requests | — |
Get the runtime environment key for a job
GET /api/v4/jobs/{id}/runtime_environment_key
Retrieves the runtime environment key linked to a job, if the job is resuming a suspended environment.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
tokenQuery | String | Authentication token of the job |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
403 | Forbidden | — |
404 | Not found | — |
429 | Too Many Requests | — |
Update the trace of a job
PATCH /api/v4/jobs/{id}/trace
Updates the trace of a job by appending a chunk of log output. Used by runners while executing a job.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the job |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
debug_ | Boolean | If true, |
token | String | Authentication token of the job |
Responses
| Code | Description | Schema |
|---|---|---|
202 | Trace was patched | — |
400 | Missing Content- | — |
403 | Forbidden | — |
404 | Not Found | — |
416 | Range not satisfiable | — |
429 | Too Many Requests | — |
List all jobs processed by a runner
GET /api/v4/runners/{id}/jobs
Lists all jobs that are being processed or were processed by a specified runner. The list of jobs is limited to projects where the user has the Reporter, Developer, Maintainer, or Owner role. When the ci_rate_limit_rest_runner_job_list_completed_statuses feature flag is enabled, requests filtered by success, failed, or canceled are rate limited per user (runner_job_list_completed_statuses_limit_per_user application setting), and statuses a runner’s jobs cannot have, such as pending, match no jobs. Until the ci_enforce_runner_job_list_completed_statuses_limit feature flag is enabled, requests over this limit are logged but not blocked. Requests that list only jobs from the user’s projects, which is every user except administrators in Admin Mode and auditors, are rate limited per user (runner_job_list_project_filtered_limit_per_user application setting). Until the ci_rate_limit_rest_runner_job_list_project_filtered feature flag is enabled, requests over this limit are logged but not blocked.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the runner |
system_Query | String | System ID associated with the runner manager |
statusQuery | String | Status of the job Allowed values: created,waiting_,preparing,waiting_,pending,running,success,failed,canceling,canceled,skipped,manual,scheduled |
order_Query | String | Sort results by the specified field Allowed values: id |
sortQuery | String | Sort results in ascending or descending order.order_ as well,idAllowed values: asc,descDefault: desc |
cursorQuery | String | Cursor for obtaining the next set of records |
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
401 | Unauthorized | — |
403 | No access granted | — |
404 | Runner not found | — |
429 | Too Many Requests | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesCiJobBasicWithProject
| Property | Type | Description |
|---|---|---|
allow_ | Boolean | — |
commit | APIEntities | — |
coverage | Number (float) | Example:98. |
created_ | String (date- | Example:2015- |
duration | Number (float) | Time spent running Example: 0. |
erased_ | String (date- | Example:2015- |
failure_ | String | Example:script_ |
finished_ | String (date- | Example:2015- |
id | Integer (int64) | Example:1 |
name | String | Example:deploy_ |
pipeline | APIEntities | — |
project | APIEntities | — |
queued_ | Number (float) | Time spent enqueued Example: 0. |
ref | String | Example:main |
stage | String | Example:deploy |
started_ | String (date- | Example:2015- |
status | String | Example:waiting_ |
tag | Boolean | — |
user | APIEntities | — |
web_ | String | Example:https: |
APIEntitiesCiJobRequestArtifacts
| Property | Type | Description |
|---|---|---|
artifact_ | String | — |
artifact_ | String | — |
exclude | Array of strings | — |
expire_ | String | — |
name | String | — |
paths | Array of strings | — |
untracked | Boolean | — |
when | String | — |
APIEntitiesCiJobRequestCache
| Property | Type | Description |
|---|---|---|
fallback_ | Array of strings | — |
key | String | — |
paths | Array of strings | — |
policy | String | — |
untracked | Boolean | — |
when | String | — |
APIEntitiesCiJobRequestCredentials
| Property | Type | Description |
|---|---|---|
password | String | — |
type | String | — |
url | String | — |
username | String | — |
APIEntitiesCiJobRequestGitInfo
| Property | Type | Description |
|---|---|---|
before_ | String | — |
depth | String | — |
protected | String | — |
ref | String | — |
ref_ | String | — |
refspecs | String | — |
repo_ | String | — |
repo_ | String | — |
sha | String | — |
APIEntitiesCiJobRequestHook
| Property | Type | Description |
|---|---|---|
name | String | — |
script | Array of strings | — |
APIEntitiesCiJobRequestImage
| Property | Type | Description |
|---|---|---|
entrypoint | String | — |
executor_ | String | — |
name | String | — |
ports | Array of APIEntities | — |
pull_ | String | — |
APIEntitiesCiJobRequestJobInfo
| Property | Type | Description |
|---|---|---|
id | String | — |
instance_ | String | — |
instance_ | String | — |
name | String | — |
namespace_ | String | — |
organization_ | String | — |
pipeline_ | String | — |
project_ | String | — |
project_ | String | — |
project_ | String | — |
project_ | String | — |
queue_ | String | — |
queue_ | String | — |
root_ | String | — |
scoped_ | String | — |
stage | String | — |
tag_ | Array of strings | Example:["docker", |
time_ | String | — |
user_ | String | — |
APIEntitiesCiJobRequestPort
| Property | Type | Description |
|---|---|---|
name | String | — |
number | Integer | — |
protocol | String | — |
APIEntitiesCiJobRequestResponse
| Property | Type | Description |
|---|---|---|
allow_ | String | — |
artifacts | Array of APIEntities | — |
cache | Array of APIEntities | — |
credentials | Array of APIEntities | — |
dependencies | String | — |
features | String | — |
git_ | APIEntities | — |
hooks | Array of APIEntities | — |
id | String | — |
image | APIEntities | — |
inputs | String | — |
job_ | APIEntities | — |
policy_ | String | — |
run | String | — |
runner_ | APIEntities | — |
secrets | String | — |
services | Array of APIEntities | — |
steps | Array of APIEntities | — |
suspend_ | String | — |
token | String | — |
variables | String | — |
APIEntitiesCiJobRequestRunnerInfo
| Property | Type | Description |
|---|---|---|
runner_ | String | — |
timeout | String | — |
uuid | String | — |
APIEntitiesCiJobRequestService
| Property | Type | Description |
|---|---|---|
alias | String | — |
command | String | — |
entrypoint | String | — |
executor_ | String | — |
name | String | — |
ports | Array of APIEntities | — |
pull_ | String | — |
variables | String | — |
APIEntitiesCiJobRequestStep
| Property | Type | Description |
|---|---|---|
allow_ | Boolean | — |
name | String | — |
script | Array of strings | — |
timeout | Integer | — |
when | String | — |
APIEntitiesCiPipelineBasic
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Timestamp when the pipeline was created Example: 2022- |
id | Integer (int64) | ID of the pipeline Example: 1 |
iid | Integer | Internal ID of the pipeline Example: 2 |
project_ | Integer (int64) | ID of the project of the pipeline Example: 3 |
ref | String | Git reference of the pipeline Example: feature- |
sha | String | SHA of the commit the pipeline runs for Example: 0ec9e58fdfca6cdd6652 |
source | String | Source that triggered the pipeline Example: push |
status | String | Status of the pipeline Example: success |
updated_ | String (date- | Timestamp when the pipeline was last updated Example: 2022- |
web_ | String | URL of the pipeline in the Git Example: https: |
APIEntitiesCiRuntimeEnvironmentKey
| Property | Type | Description |
|---|---|---|
runtime_ | String | Example:42/ |
APIEntitiesCommit
| Property | Type | Description |
|---|---|---|
author_ | String | Email address of the commit author Example: john@example. |
author_ | String | Name of the commit author Example: John Smith |
authored_ | String (date- | Date and time when the commit was authored Example: 2012- |
committed_ | String (date- | Date and time when the commit was committed Example: 2012- |
committer_ | String | Email address of the committer Example: jack@example. |
committer_ | String | Name of the committer Example: Jack Smith |
created_ | String (date- | Date and time when the commit was created.committed_Example: 2017- |
extended_ | Object | Git trailers parsed from the commit message, Example: {"Signed- |
id | String | Full SHA of the commit Example: 2695effb5807a22ff3d1 |
message | String | Full commit message Example: Initial commit |
parent_ | Array of strings | SHAs of the parent commits Example: ["2a4b78934375d7f53875 |
short_ | String | Short SHA of the commit Example: 2695effb |
title | String | Title of the commit message Example: Initial commit |
trailers | Object | Git trailers parsed from the commit message. Example: {"Merged- |
web_ | String | URL to view the commit in the Git Example: https: |
APIEntitiesCustomAttribute
| Property | Type | Description |
|---|---|---|
key | String | Example:foo |
value | String | Example:bar |
APIEntitiesProjectIdentity
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2020- |
description | String | Example:desc |
id | Integer (int64) | Example:1 |
name | String | Example:project1 |
name_ | String | Example:John Doe / |
path | String | Example:project1 |
path_ | String | Example:namespace1/ |
APIEntitiesUser
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:/ |
avatar_ | String | URL of the user’s avatar Example: https: |
bio | String | Biography of the user |
bot | Boolean | — |
created_ | String (date- | Creation date and time of the user account in ISO 8601 format |
custom_ | Array of APIEntities | — |
discord | String | Discord user ID of the user |
followers | String | — |
following | String | — |
github | String | Git |
id | Integer (int64) | ID of the user Example: 1 |
is_ | String | — |
job_ | String | Job title of the user |
linkedin | String | Linked |
local_ | String | — |
location | String | Location of the user |
locked | Boolean | If true, |
name | String | Name of the user.**** if the current user cannot read the bot’s project or groupExample: Administrator |
organization | String | Organization of the user |
pronouns | String | Pronouns of the user |
public_ | String | Public email address of the user Example: john@example. |
state | String | State of the user account.active,blocked,ldap_,blocked_,banned,deactivatedExample: active |
twitter | String | Twitter username of the user |
username | String | Username of the user Example: admin |
web_ | String | URL of the user’s profile Example: https: |
website_ | String | Website of the user |
work_ | String | — |