Fix the pipeline ID and PR URL for GitLab CI (#3763)

* Use Merge Request Instance ID instead of the Merge Request ID for GitLab CI.

* Use GitLab Pipeline Instance ID as the BuildID for GitLab CI.

* Update the changelog.

* Update the test for GitLab CI detection.
This commit is contained in:
Praneet Loke 2020-01-16 14:59:12 -08:00 committed by GitHub
parent 223e0c5e83
commit 39a4abe32d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -13,6 +13,8 @@ CHANGELOG
- Add `pulumi policy ls` and `pulumi policy group ls` to list Policy related resources.
- Update GitLab CI detection code for setting an update's `BuildID` and `PRNumber` metadata properties. [#3763](https://github.com/pulumi/pulumi/pull/3763)
## 1.8.1 (2019-12-20)
- Fix a panic in `pulumi stack select`. [#3687](https://github.com/pulumi/pulumi/pull/3687)

View file

@ -27,13 +27,13 @@ type gitlabCI struct {
// See https://docs.gitlab.com/ee/ci/variables/.
func (gl gitlabCI) DetectVars() Vars {
v := Vars{Name: gl.Name}
v.BuildID = os.Getenv("CI_JOB_ID")
v.BuildID = os.Getenv("CI_PIPELINE_IID")
v.BuildType = os.Getenv("CI_PIPELINE_SOURCE")
v.BuildURL = os.Getenv("CI_JOB_URL")
v.SHA = os.Getenv("CI_COMMIT_SHA")
v.BranchName = os.Getenv("CI_COMMIT_REF_NAME")
v.CommitMessage = os.Getenv("CI_COMMIT_MESSAGE")
v.PRNumber = os.Getenv("CI_MERGE_REQUEST_ID")
v.PRNumber = os.Getenv("CI_MERGE_REQUEST_IID")
return v
}

View file

@ -49,9 +49,9 @@ func TestDetectVars(t *testing.T) {
"PULUMI_CI_BUILD_ID": buildID,
},
GitLab: {
"TRAVIS": "",
"GITLAB_CI": "true",
"CI_JOB_ID": buildID,
"TRAVIS": "",
"GITLAB_CI": "true",
"CI_PIPELINE_IID": buildID,
},
Travis: {
"TRAVIS": "true",