3

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?

Adam Marshall
  • 6,369
  • 1
  • 29
  • 45
tikurilla
  • 31
  • 1
  • 4

1 Answers1

2

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"
}
Adam Marshall
  • 6,369
  • 1
  • 29
  • 45
  • Thanks for your help. Actually in my case it's better to use create pipeline api instead of trigger pipeline. – tikurilla Oct 11 '21 at 02:59