From c9034b21322bbc73ea2d2f825aa6e4abcfecb5dd Mon Sep 17 00:00:00 2001 From: Rieken Date: Wed, 21 Aug 2019 15:02:49 -0400 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20added=20flag=20to=20bypass=20jira/i?= =?UTF-8?q?ssues=20check,=20=F0=9F=A4=96=F0=9F=A6=8D=F0=9F=90=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/usage/bitbucket_server.html.md | 4 +++ .../bitbucket_server/BitBucketServerAPI.ts | 3 ++ .../_tests/_bitbucket_server_api.test.ts | 35 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/docs/usage/bitbucket_server.html.md b/docs/usage/bitbucket_server.html.md index 960dac48d..a3d82ba00 100644 --- a/docs/usage/bitbucket_server.html.md +++ b/docs/usage/bitbucket_server.html.md @@ -93,3 +93,7 @@ export http_proxy=http://127.0.0.1:8080 or export https_proxy=https://127.0.0.1:8080 ``` + +If you are using Bitbucket but not using Jira/Issues you can add an environment variable to bypass the check: + +- `DANGER_NO_BITBUCKET_JIRA_INTEGRATION` Bypass Jira/Issues integration diff --git a/source/platforms/bitbucket_server/BitBucketServerAPI.ts b/source/platforms/bitbucket_server/BitBucketServerAPI.ts index 117c889d1..221b0279c 100644 --- a/source/platforms/bitbucket_server/BitBucketServerAPI.ts +++ b/source/platforms/bitbucket_server/BitBucketServerAPI.ts @@ -193,6 +193,9 @@ export class BitBucketServerAPI implements BitBucketServerAPIDSL { } getIssues = async (): Promise => { + if (process.env.DANGER_NO_BITBUCKET_JIRA_INTEGRATION) { + return [] as JIRAIssue[] + } const path = `${this.getPRBasePath("jira")}/issues` const res = await this.get(path) throwIfNotOk(res) diff --git a/source/platforms/bitbucket_server/_tests/_bitbucket_server_api.test.ts b/source/platforms/bitbucket_server/_tests/_bitbucket_server_api.test.ts index 1a8d602fe..8d3f92d1f 100644 --- a/source/platforms/bitbucket_server/_tests/_bitbucket_server_api.test.ts +++ b/source/platforms/bitbucket_server/_tests/_bitbucket_server_api.test.ts @@ -163,6 +163,41 @@ describe("API testing - BitBucket Server", () => { expect(result).toEqual({ issue: "key" }) }) + describe("getIssues", () => { + const OLD_ENV = process.env + + beforeEach(() => { + jest.resetModules() + process.env = { ...OLD_ENV } + delete process.env.DANGER_NO_BITBUCKET_JIRA_INTEGRATION + }) + + afterEach(() => { + process.env = OLD_ENV + }) + + it("returns Issue", async () => { + jsonResult = () => ({ issue: "key" }) + const result = await api.getIssues() + + expect(api.fetch).toHaveBeenCalledWith( + `${host}/rest/jira/1.0/projects/FOO/repos/BAR/pull-requests/1/issues`, + { method: "GET", body: null, headers: expectedJSONHeaders }, + undefined + ) + expect(result).toEqual({ issue: "key" }) + }) + + it("bypass getIssues if DANGER_NO_BITBUCKET_JIRA_INTEGRATION is set", async () => { + process.env.DANGER_NO_BITBUCKET_JIRA_INTEGRATION = "true" + jsonResult = () => ({ issue: "key" }) + const result = await api.getIssues() + + expect(api.fetch).not.toHaveBeenCalled() + expect(result).toEqual([]) + }) + }) + it("getDangerComments", async () => { const commitID = "e70f3d6468f61a4bef68c9e6eaba9166b096e23c" jsonResult = () => ({ From f3d81c055f418de3d2d7c10c8aff8a0044f075e0 Mon Sep 17 00:00:00 2001 From: Rieken Date: Wed, 21 Aug 2019 15:49:34 -0400 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20updated=20changelog=20for=20jira/is?= =?UTF-8?q?sues=20check,=20=F0=9F=A4=96=F0=9F=A6=8D=F0=9F=90=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd158432e..325da1254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ +- Added flag to bypass Jira/Issues - [@orieken] + # 9.1.8 - Get GitHub Actions event file pathname from env variable - [@IljaDaderko]