tikurilla
tikurilla

Reputation: 31

Getting pipeline ID after triggering that pipeline in Gitlab

I use Gitlab CI/CD for deploying my projects. I use Gitlab REST API for manipulating with pipelines. For starting pipeline I can use this endpoint:

POST /projects/:id/trigger/pipeline

response for that request something like this:

{
    "ref": "master_branch",
    "status": "pending"
}

.. and nothing about triggered pipeline ID.

Also I want to know some info about triggered pipeline using:

GET /projects/:id/pipelines/:pipeline_id

.. but I don't know pipeline ID.

Yes, I know about list of pipelines with GET /projects/:id/pipelines, but it is not what I actually want.

How to know trigger pipeline ID?

Upvotes: 3

Views: 5049

Answers (1)

Adam Marshall
Adam Marshall

Reputation: 7649

The response to the Create Pipeline API operation gives you both the instance-wide Pipeline ID (called id) and the project-specific ID (called iid), The id is what you'd see in the list of Pipelines for a project and what you'd use in other API calls.

Here's the example response from the docs:

{
  "id": 61,
  "iid": 21,
  "project_id": 1,
  "sha": "384c444e840a515b23f21915ee5766b87068a70d",
  "ref": "main",
  "status": "pending",
  "before_sha": "0000000000000000000000000000000000000000",
  "tag": false,
  "yaml_errors": null,
  "user": {
    "name": "Administrator",
    "username": "root",
    "id": 1,
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
    "web_url": "http://localhost:3000/root"
  },
  "created_at": "2016-11-04T09:36:13.747Z",
  "updated_at": "2016-11-04T09:36:13.977Z",
  "started_at": null,
  "finished_at": null,
  "committed_at": null,
  "duration": null,
  "queued_duration": 0.010,
  "coverage": null,
  "web_url": "https://example.com/foo/bar/pipelines/61"
}

Upvotes: 3

Related Questions