ci_triggers

Trigger a pipeline with a token

Triggers a pipeline with a token. With a CI/CD job token, the triggered pipeline is a multi-project pipeline. The job that authenticates the request becomes associated with the upstream pipeline, which is visible on the pipeline graph. If you use a trigger token in a job, the job is not associated with the upstream pipeline.

post/api/v4/projects/{id}/(ref/{ref}/)trigger/pipeline

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idstring required

The ID or URL-encoded path of the project

refstring required

The commit sha or name of a branch or tag

Request body

tokenstring required

The unique token of trigger or job token

variablesobject

The list of variables to be injected into build

inputsobject

The list of inputs to be used to create the pipeline.

Example request

{
  "token": "6d056f63e50fe6f8c5f8f4aa10edb7",
  "variables": {
    "VAR1": "value1",
    "VAR2": "value2"
  }
}

Response

Trigger a pipeline with a token

idinteger required
iidinteger required
project_idinteger required
shastring required
refstring required
statusstring required
sourcestring required
created_atstring date-time required
updated_atstring date-time required
web_urlstring required
before_shastring required
tagboolean required
yaml_errorsstring required
started_atstring date-time required
finished_atstring date-time required
committed_atstring date-time required
durationinteger required

Time spent running in seconds

queued_durationinteger required

Time spent enqueued in seconds

coveragenumber float required
archivedboolean required

Example response

{
  "id": 1,
  "iid": 2,
  "project_id": 3,
  "sha": "0ec9e58fdfca6cdd6652c083c9edb53abc0bad52",
  "ref": "feature-branch",
  "status": "success",
  "source": "push",
  "created_at": "2015-12-24T15:51:21.880Z",
  "updated_at": "2015-12-24T17:54:31.198Z",
  "web_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/pipelines/61",
  "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
  "yaml_errors": "widgets:build: needs 'widgets:test'",
  "user": {
    "id": 1,
    "username": "admin",
    "public_email": "john@example.com",
    "name": "Administrator",
    "state": "active",
    "avatar_url": "https://gravatar.com/avatar/1",
    "avatar_path": "/user/avatar/28/The-Big-Lebowski-400-400.png",
    "custom_attributes": [
      {
        "key": "foo",
        "value": "bar"
      }
    ],
    "web_url": "https://gitlab.example.com/root"
  },
  "started_at": "2015-12-24T17:54:30.733Z",
  "finished_at": "2015-12-24T17:54:31.198Z",
  "committed_at": "2015-12-24T15:51:21.880Z",
  "duration": 127,
  "queued_duration": 63,
  "coverage": 98.29,
  "detailed_status": {
    "icon": "status_success",
    "text": "passed",
    "label": "passed",
    "group": "success",
    "tooltip": "passed",
    "has_details": true,
    "details_path": "/test-group/test-project/-/pipelines/287",
    "illustration": {
      "image": "illustrations/empty-state/empty-job-not-triggered-md.svg",
      "size": "",
      "title": "This job has not been triggered yet",
      "content": "This job depends on upstream jobs that need to succeed in order for this job to be triggered"
    },
    "favicon": "/assets/ci_favicons/favicon_status_success.png",
    "action": {
      "icon": "cancel",
      "title": "Cancel",
      "path": "/namespace1/project1/-/jobs/2/cancel",
      "method": "post",
      "button_title": "Cancel this job",
      "confirmation_message": "Are you sure?"
    }
  }
}

Changes

No recorded changes to this operation across all 5 revisions of this API.