Skip to content

Commit

Permalink
feat: added flag to bypass jira/issues check, πŸ€–πŸ¦πŸ™
Browse files Browse the repository at this point in the history
  • Loading branch information
Rieken committed Aug 21, 2019
1 parent fbcbc6a commit c9034b2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/usage/bitbucket_server.html.md
Expand Up @@ -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
3 changes: 3 additions & 0 deletions source/platforms/bitbucket_server/BitBucketServerAPI.ts
Expand Up @@ -193,6 +193,9 @@ export class BitBucketServerAPI implements BitBucketServerAPIDSL {
}

getIssues = async (): Promise<JIRAIssue[]> => {
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)
Expand Down
Expand Up @@ -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 = () => ({
Expand Down

0 comments on commit c9034b2

Please sign in to comment.