diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7e0edd0..ad736cf6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ +- Take commit hash from bitrise env - [@f-meloni] + # 9.1.4 - Use new env `BITBUCKET_REPO_FULL_NAME` in bitbucket pipeline. - [@Soyn] diff --git a/source/ci_source/providers/Bitrise.ts b/source/ci_source/providers/Bitrise.ts index 0bd09ada3..641448ddc 100644 --- a/source/ci_source/providers/Bitrise.ts +++ b/source/ci_source/providers/Bitrise.ts @@ -72,6 +72,10 @@ export class Bitrise implements CISource { } get ciRunURL() { - return process.env.BITRISE_PULL_REQUEST + return this.env.BITRISE_PULL_REQUEST + } + + get commitHash() { + return this.env.BITRISE_GIT_COMMIT } } diff --git a/source/ci_source/providers/_tests/_bitrise.test.ts b/source/ci_source/providers/_tests/_bitrise.test.ts index 721e686e1..def8c0781 100644 --- a/source/ci_source/providers/_tests/_bitrise.test.ts +++ b/source/ci_source/providers/_tests/_bitrise.test.ts @@ -73,3 +73,19 @@ describe(".repoSlug", () => { expect(bitrise.repoSlug).toEqual("artsy/eigen") }) }) + +describe("commit hash", () => { + it("returns correct commit hash when present", () => { + const env = { + ...correctEnv, + BITRISE_GIT_COMMIT: "1234abc", + } + const bitrise = new Bitrise(env) + expect(bitrise.commitHash).toEqual("1234abc") + }) + + it("returns no commit hash when not present", () => { + const bitrise = new Bitrise(correctEnv) + expect(bitrise.commitHash).toBeUndefined() + }) +})