Fares
Fares

Reputation: 1600

How to get the Pipeline #XXXXXXXXX value displayed on gitlab UI inside .gitlab-ci.yml

The title pretty much says it all. I want to be able to get the value below as an environment variable in my .gitlab-ci.yml Pipeline value I wish to get

I tried both ${CI_PIPELINE_ID} and ${CI_PIPELINE_IID} but in the first case I got an incremental value and in the second I got a different value from the one displayed below.

Does anyone know how to?

Thanks in advance

Upvotes: 1

Views: 9024

Answers (1)

DV82XL
DV82XL

Reputation: 6629

Try running the command printenv in one of your jobs. It will print out all environment variables and their values. The correct variable you're looking for is CI_PIPELINE_ID. Here's what I got:

CI_PIPELINE_ID=396845
CI_PIPELINE_IID=2726
  • CI_PIPELINE_ID: The unique id of the current pipeline that GitLab CI uses internally
  • CI_PIPELINE_IID: The unique id of the current pipeline scoped to project.

Personally, I always use CI_PIPELINE_ID.

Upvotes: 3

Related Questions