diff --git a/source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts b/source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts index b24a23233..3bcebd924 100644 --- a/source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts +++ b/source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts @@ -19,7 +19,7 @@ import { RepoMetaData } from "../../dsl/BitBucketServerDSL" export type BitBucketCloudCredentials = { /** Unique ID for this user, must be wrapped with brackets */ - uuid: string + uuid?: string } & (BitBucketCloudCredentialsOAuth | BitBucketCloudCredentialsPassword) interface BitBucketCloudCredentialsOAuth { @@ -35,8 +35,8 @@ interface BitBucketCloudCredentialsPassword { } export function bitbucketCloudCredentialsFromEnv(env: Env): BitBucketCloudCredentials { - const uuid = `${env["DANGER_BITBUCKETCLOUD_UUID"]}` - if (uuid.length > 0) { + const uuid: string | undefined = env["DANGER_BITBUCKETCLOUD_UUID"] + if (uuid != null && uuid.length > 0) { if (!uuid.startsWith("{") || !uuid.endsWith("}")) { throw new Error(`DANGER_BITBUCKETCLOUD_UUID must be wraped with brackets`) } @@ -83,9 +83,7 @@ export class BitBucketCloudAPI { this.fetch = fetch // Backward compatible, - if (credentials.uuid.length > 0) { - this.uuid = credentials.uuid - } + this.uuid = credentials.uuid } getBaseRepoURL() { diff --git a/source/platforms/bitbucket_cloud/_tests_/_bitbucket_cloud_api.test.ts b/source/platforms/bitbucket_cloud/_tests_/_bitbucket_cloud_api.test.ts index 7dc7e8985..1625b692e 100644 --- a/source/platforms/bitbucket_cloud/_tests_/_bitbucket_cloud_api.test.ts +++ b/source/platforms/bitbucket_cloud/_tests_/_bitbucket_cloud_api.test.ts @@ -390,7 +390,6 @@ describe("API testing - BitBucket Cloud", () => { type: "PASSWORD", username: "foo", password: "bar", - uuid: "", } ) let requestNo = 0 @@ -425,7 +424,6 @@ describe("API testing - BitBucket Cloud", () => { type: "OAUTH", oauthSecret: "superSecretOAUTH", oauthKey: "superOAUTHKey", - uuid: "", } ) let requestNo = 0 @@ -464,7 +462,6 @@ describe("API testing - BitBucket Cloud", () => { type: "OAUTH", oauthSecret: "superSecretOAUTH", oauthKey: "superOAUTHKey", - uuid: "", } ) let requestNo = 0 @@ -500,7 +497,6 @@ describe("API testing - BitBucket Cloud", () => { type: "OAUTH", oauthSecret: "superSecretOAUTH", oauthKey: "superOAUTHKey", - uuid: "", } )