@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.2.7-next.1 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-bitbucket-cloud
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - c56a279: Added `bitbucketCloud:branchRestriction:create` to allow users to create bitbucket cloud branch restrictions in templates
8
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
9
+ - e279c30: Fixing spelling mistake in `jsonschema`
10
+ - Updated dependencies
11
+ - @backstage/integration@1.16.2
12
+ - @backstage/plugin-scaffolder-node@0.8.0
13
+ - @backstage/backend-plugin-api@1.2.1
14
+ - @backstage/config@1.3.2
15
+ - @backstage/errors@1.2.7
16
+ - @backstage/plugin-bitbucket-cloud-common@0.2.28
17
+
18
+ ## 0.2.7-next.2
19
+
20
+ ### Patch Changes
21
+
22
+ - c56a279: Added `bitbucketCloud:branchRestriction:create` to allow users to create bitbucket cloud branch restrictions in templates
23
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
24
+ - e279c30: Fixing spelling mistake in `jsonschema`
25
+ - Updated dependencies
26
+ - @backstage/plugin-scaffolder-node@0.8.0-next.2
27
+ - @backstage/integration@1.16.2-next.0
28
+ - @backstage/backend-plugin-api@1.2.1-next.1
29
+ - @backstage/config@1.3.2
30
+ - @backstage/errors@1.2.7
31
+ - @backstage/plugin-bitbucket-cloud-common@0.2.28-next.0
32
+
3
33
  ## 0.2.7-next.1
4
34
 
5
35
  ### Patch Changes
@@ -96,6 +96,11 @@ function createPublishBitbucketCloudAction(options) {
96
96
  title: "Authentication Token",
97
97
  type: "string",
98
98
  description: "The token to use for authorization to BitBucket Cloud"
99
+ },
100
+ signCommit: {
101
+ title: "Sign commit",
102
+ type: "boolean",
103
+ description: "Sign commit with configured PGP private key"
99
104
  }
100
105
  }
101
106
  },
@@ -123,7 +128,8 @@ function createPublishBitbucketCloudAction(options) {
123
128
  description,
124
129
  defaultBranch = "master",
125
130
  gitCommitMessage,
126
- repoVisibility = "private"
131
+ repoVisibility = "private",
132
+ signCommit
127
133
  } = ctx.input;
128
134
  const { workspace, project, repo, host } = pluginScaffolderNode.parseRepoUrl(
129
135
  repoUrl,
@@ -180,6 +186,12 @@ function createPublishBitbucketCloudAction(options) {
180
186
  password: integrationConfig.config.appPassword
181
187
  };
182
188
  }
189
+ const signingKey = integrationConfig.config.commitSigningKey ?? config.getOptionalString("scaffolder.defaultCommitSigningKey");
190
+ if (signCommit && !signingKey) {
191
+ throw new Error(
192
+ "Signing commits is enabled but no signing key is provided in the configuration"
193
+ );
194
+ }
183
195
  const commitResult = await pluginScaffolderNode.initRepoAndPush({
184
196
  dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
185
197
  remoteUrl,
@@ -187,7 +199,8 @@ function createPublishBitbucketCloudAction(options) {
187
199
  defaultBranch,
188
200
  logger: ctx.logger,
189
201
  commitMessage: gitCommitMessage || config.getOptionalString("scaffolder.defaultCommitMessage"),
190
- gitAuthorInfo
202
+ gitAuthorInfo,
203
+ signingKey: signCommit ? signingKey : void 0
191
204
  });
192
205
  ctx.output("commitHash", commitResult?.commitHash);
193
206
  ctx.output("remoteUrl", remoteUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloud.cjs.js","sources":["../../src/actions/bitbucketCloud.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\n\nimport { Config } from '@backstage/config';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloud.examples';\n\nconst createRepository = async (opts: {\n workspace: string;\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n mainBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n project,\n repo,\n description,\n repoVisibility,\n mainBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n scm: 'git',\n description: description,\n is_private: repoVisibility === 'private',\n project: { key: project },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n let response: Response;\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n let remoteUrl = '';\n for (const link of r.links.clone) {\n if (link.name === 'https') {\n remoteUrl = link.href;\n }\n }\n\n // \"mainbranch.name\" cannot be set neither at create nor update of the repo\n // the first pushed branch will be set as \"main branch\" then\n const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;\n return { remoteUrl, repoContentsUrl };\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Bitbucket Cloud.\n * @public\n */\nexport function createPublishBitbucketCloudAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n repoVisibility?: 'private' | 'public';\n gitCommitMessage?: string;\n sourcePath?: string;\n token?: string;\n }>({\n id: 'publish:bitbucketCloud',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n repoVisibility: {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public'],\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n sourcePath: {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The token to use for authorization to BitBucket Cloud',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitCommitMessage,\n repoVisibility = 'private',\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n if (!project) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const { remoteUrl, repoContentsUrl } = await createRepository({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n });\n\n const gitAuthorInfo = {\n name: config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage:\n gitCommitMessage ||\n config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AA6BA,MAAM,gBAAA,GAAmB,OAAO,IAS1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAA,MAAM,OAAuB,GAAA;AAAA,IAC3B,MAAQ,EAAA,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,GAA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ACA,MAAO,CAAA,iBAAA,CAAkB,iCAAiC,CAAA;AAAA,QAC5D;AAAA,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"bitbucketCloud.cjs.js","sources":["../../src/actions/bitbucketCloud.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\n\nimport { Config } from '@backstage/config';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloud.examples';\n\nconst createRepository = async (opts: {\n workspace: string;\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n mainBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n project,\n repo,\n description,\n repoVisibility,\n mainBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n scm: 'git',\n description: description,\n is_private: repoVisibility === 'private',\n project: { key: project },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n let response: Response;\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n let remoteUrl = '';\n for (const link of r.links.clone) {\n if (link.name === 'https') {\n remoteUrl = link.href;\n }\n }\n\n // \"mainbranch.name\" cannot be set neither at create nor update of the repo\n // the first pushed branch will be set as \"main branch\" then\n const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;\n return { remoteUrl, repoContentsUrl };\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Bitbucket Cloud.\n * @public\n */\nexport function createPublishBitbucketCloudAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n repoVisibility?: 'private' | 'public';\n gitCommitMessage?: string;\n sourcePath?: string;\n token?: string;\n signCommit?: boolean;\n }>({\n id: 'publish:bitbucketCloud',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n repoVisibility: {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public'],\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n sourcePath: {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The token to use for authorization to BitBucket Cloud',\n },\n signCommit: {\n title: 'Sign commit',\n type: 'boolean',\n description: 'Sign commit with configured PGP private key',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitCommitMessage,\n repoVisibility = 'private',\n signCommit,\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n if (!project) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const { remoteUrl, repoContentsUrl } = await createRepository({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n });\n\n const gitAuthorInfo = {\n name: config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage:\n gitCommitMessage ||\n config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AA6BA,MAAM,gBAAA,GAAmB,OAAO,IAS1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAA,MAAM,OAAuB,GAAA;AAAA,IAC3B,MAAQ,EAAA,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,GAAK,EAAA,KAAA;AAAA,MACL,WAAA;AAAA,MACA,YAAY,cAAmB,KAAA,SAAA;AAAA,MAC/B,OAAA,EAAS,EAAE,GAAA,EAAK,OAAQ;AAAA,KACzB,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,aAAe,EAAA,aAAA;AAAA,MACf,cAAgB,EAAA;AAAA;AAClB,GACF;AAEA,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA,MACf,CAAG,EAAA,UAAU,CAAiB,cAAA,E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AAA,iBAAA,CAAkB,iCAAiC,CAAA;AAAA,QAC5D,aAAA;AAAA,QACA,UAAA,EAAY,aAAa,UAAa,GAAA,KAAA;AAAA,OACvC,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+
3
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
+ var errors = require('@backstage/errors');
5
+ var helpers = require('./helpers.cjs.js');
6
+ var inputProperties = require('./inputProperties.cjs.js');
7
+ var bitbucketCloudBranchRestriction_examples = require('./bitbucketCloudBranchRestriction.examples.cjs.js');
8
+
9
+ const createBitbucketCloudBranchRestriction = async (opts) => {
10
+ const {
11
+ workspace,
12
+ repo,
13
+ kind,
14
+ branchMatchKind,
15
+ branchType,
16
+ pattern,
17
+ value,
18
+ users,
19
+ groups,
20
+ authorization
21
+ } = opts;
22
+ const bitbucket = helpers.getBitbucketClient(authorization);
23
+ return await bitbucket.branchrestrictions.create({
24
+ _body: {
25
+ groups,
26
+ users,
27
+ branch_match_kind: branchMatchKind,
28
+ kind,
29
+ type: "branchrestriction",
30
+ value: kind === "push" ? null : value,
31
+ pattern: branchMatchKind === "glob" ? pattern : void 0,
32
+ branch_type: branchMatchKind === "branching_model" ? branchType : void 0
33
+ },
34
+ repo_slug: repo,
35
+ workspace
36
+ });
37
+ };
38
+ function createBitbucketCloudBranchRestrictionAction(options) {
39
+ const { integrations } = options;
40
+ return pluginScaffolderNode.createTemplateAction({
41
+ id: "bitbucketCloud:branchRestriction:create",
42
+ examples: bitbucketCloudBranchRestriction_examples.examples,
43
+ description: "Creates branch restrictions for a Bitbucket Cloud repository.",
44
+ schema: {
45
+ input: {
46
+ type: "object",
47
+ required: ["repoUrl", "kind"],
48
+ properties: {
49
+ repoUrl: inputProperties.repoUrl,
50
+ kind: inputProperties.restriction.kind,
51
+ branchMatchKind: inputProperties.restriction.branchMatchKind,
52
+ branchType: inputProperties.restriction.branchType,
53
+ pattern: inputProperties.restriction.pattern,
54
+ value: inputProperties.restriction.value,
55
+ users: inputProperties.restriction.users,
56
+ groups: inputProperties.restriction.groups,
57
+ token: inputProperties.token
58
+ }
59
+ },
60
+ output: {
61
+ type: "object",
62
+ properties: {
63
+ json: {
64
+ title: "The response from bitbucket cloud",
65
+ type: "string"
66
+ },
67
+ statusCode: {
68
+ title: "The status code of the response",
69
+ type: "number"
70
+ }
71
+ }
72
+ }
73
+ },
74
+ async handler(ctx) {
75
+ const {
76
+ repoUrl,
77
+ kind,
78
+ branchMatchKind = "branching_model",
79
+ branchType = "development",
80
+ pattern = "",
81
+ value = 1,
82
+ users = [],
83
+ groups = [],
84
+ token = ""
85
+ } = ctx.input;
86
+ const { workspace, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
87
+ if (!workspace) {
88
+ throw new errors.InputError(
89
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
90
+ );
91
+ }
92
+ const integrationConfig = integrations.bitbucketCloud.byHost(host);
93
+ if (!integrationConfig) {
94
+ throw new errors.InputError(
95
+ `No matching integration configuration for host ${host}, please check your integrations config`
96
+ );
97
+ }
98
+ const authorization = token ? { token } : integrationConfig.config;
99
+ const response = await createBitbucketCloudBranchRestriction({
100
+ workspace,
101
+ repo,
102
+ kind,
103
+ branchMatchKind,
104
+ branchType,
105
+ pattern,
106
+ value,
107
+ users: users.map((user) => ({ uuid: user.uuid, type: "user" })),
108
+ groups: groups.map((group) => ({ slug: group.slug, type: "group" })),
109
+ authorization
110
+ });
111
+ if (response.data.errors) {
112
+ ctx.logger.error(
113
+ `Error from Bitbucket Cloud Branch Restrictions: ${JSON.stringify(
114
+ response.data.errors
115
+ )}`
116
+ );
117
+ }
118
+ ctx.logger.info(
119
+ `Response from Bitbucket Cloud: ${JSON.stringify(response)}`
120
+ );
121
+ ctx.output("statusCode", response.status);
122
+ ctx.output("json", JSON.stringify(response));
123
+ }
124
+ });
125
+ }
126
+
127
+ exports.createBitbucketCloudBranchRestrictionAction = createBitbucketCloudBranchRestrictionAction;
128
+ //# sourceMappingURL=bitbucketCloudBranchRestriction.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucketCloudBranchRestriction.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { getBitbucketClient } from './helpers';\nimport * as inputProps from './inputProperties';\nimport { examples } from './bitbucketCloudBranchRestriction.examples';\n\nconst createBitbucketCloudBranchRestriction = async (opts: {\n workspace: string;\n repo: string;\n kind: string;\n branchMatchKind?: string;\n branchType?: string;\n pattern?: string;\n value?: number;\n users?: { uuid: string; type: string }[];\n groups?: { slug: string; type: string }[];\n authorization: {\n token?: string;\n username?: string;\n appPassword?: string;\n };\n}) => {\n const {\n workspace,\n repo,\n kind,\n branchMatchKind,\n branchType,\n pattern,\n value,\n users,\n groups,\n authorization,\n } = opts;\n\n const bitbucket = getBitbucketClient(authorization);\n return await bitbucket.branchrestrictions.create({\n _body: {\n groups: groups,\n users: users,\n branch_match_kind: branchMatchKind,\n kind: kind,\n type: 'branchrestriction',\n value: kind === 'push' ? null : value,\n pattern: branchMatchKind === 'glob' ? pattern : undefined,\n branch_type:\n branchMatchKind === 'branching_model' ? branchType : undefined,\n },\n repo_slug: repo,\n workspace: workspace,\n });\n};\n\n/**\n * Creates a new action that adds a branch restriction to a Bitbucket Cloud repository.\n * @public\n */\nexport function createBitbucketCloudBranchRestrictionAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n return createTemplateAction<{\n repoUrl: string;\n kind: string;\n branchMatchKind?: string;\n branchType?: string;\n pattern?: string;\n value?: number;\n users?: { uuid: string }[];\n groups?: { slug: string }[];\n token?: string;\n }>({\n id: 'bitbucketCloud:branchRestriction:create',\n examples,\n description:\n 'Creates branch restrictions for a Bitbucket Cloud repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'kind'],\n properties: {\n repoUrl: inputProps.repoUrl,\n kind: inputProps.restriction.kind,\n branchMatchKind: inputProps.restriction.branchMatchKind,\n branchType: inputProps.restriction.branchType,\n pattern: inputProps.restriction.pattern,\n value: inputProps.restriction.value,\n users: inputProps.restriction.users,\n groups: inputProps.restriction.groups,\n token: inputProps.token,\n },\n },\n output: {\n type: 'object',\n properties: {\n json: {\n title: 'The response from bitbucket cloud',\n type: 'string',\n },\n statusCode: {\n title: 'The status code of the response',\n type: 'number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n kind,\n branchMatchKind = 'branching_model',\n branchType = 'development',\n pattern = '',\n value = 1,\n users = [],\n groups = [],\n token = '',\n } = ctx.input;\n\n const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const authorization = token ? { token: token } : integrationConfig.config;\n\n const response = await createBitbucketCloudBranchRestriction({\n workspace: workspace,\n repo,\n kind: kind,\n branchMatchKind: branchMatchKind,\n branchType: branchType,\n pattern: pattern,\n value: value,\n users: users.map(user => ({ uuid: user.uuid, type: 'user' })),\n groups: groups.map(group => ({ slug: group.slug, type: 'group' })),\n authorization,\n });\n if (response.data.errors) {\n ctx.logger.error(\n `Error from Bitbucket Cloud Branch Restrictions: ${JSON.stringify(\n response.data.errors,\n )}`,\n );\n }\n ctx.logger.info(\n `Response from Bitbucket Cloud: ${JSON.stringify(response)}`,\n );\n ctx.output('statusCode', response.status);\n ctx.output('json', JSON.stringify(response));\n },\n });\n}\n"],"names":["getBitbucketClient","createTemplateAction","examples","inputProps.repoUrl","inputProps.restriction","inputProps.token","parseRepoUrl","InputError"],"mappings":";;;;;;;;AAyBA,MAAM,qCAAA,GAAwC,OAAO,IAe/C,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAM,MAAA,SAAA,GAAYA,2BAAmB,aAAa,CAAA;AAClD,EAAO,OAAA,MAAM,SAAU,CAAA,kBAAA,CAAmB,MAAO,CAAA;AAAA,IAC/C,KAAO,EAAA;AAAA,MACL,MAAA;AAAA,MACA,KAAA;AAAA,MACA,iBAAmB,EAAA,eAAA;AAAA,MACnB,IAAA;AAAA,MACA,IAAM,EAAA,mBAAA;AAAA,MACN,KAAA,EAAO,IAAS,KAAA,MAAA,GAAS,IAAO,GAAA,KAAA;AAAA,MAChC,OAAA,EAAS,eAAoB,KAAA,MAAA,GAAS,OAAU,GAAA,KAAA,CAAA;AAAA,MAChD,WAAA,EACE,eAAoB,KAAA,iBAAA,GAAoB,UAAa,GAAA,KAAA;AAAA,KACzD;AA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AO,CAAA,KAAA;AAAA,UACT,mDAAmD,IAAK,CAAA,SAAA;AAAA,YACtD,SAAS,IAAK,CAAA;AAAA,WACf,CAAA;AAAA,SACH;AAAA;AAEF,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,QACT,CAAkC,+BAAA,EAAA,IAAA,CAAK,SAAU,CAAA,QAAQ,CAAC,CAAA;AAAA,OAC5D;AACA,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,QAAA,CAAS,MAAM,CAAA;AACxC,MAAA,GAAA,CAAI,MAAO,CAAA,MAAA,EAAQ,IAAK,CAAA,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA;AAC7C,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "restrict push to the main branch, except for alice, bob, and the admins group",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "createBranchRestriction",
16
+ action: "bitbucketCloud:branchRestriction:create",
17
+ name: "Create Bitbucket Cloud branch restriction",
18
+ input: {
19
+ repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
20
+ kind: "push",
21
+ users: [
22
+ {
23
+ uuid: "{a-b-c-d}"
24
+ },
25
+ {
26
+ uuid: "{e-f-g-h}"
27
+ }
28
+ ],
29
+ groups: [
30
+ {
31
+ slug: "admins"
32
+ }
33
+ ]
34
+ }
35
+ }
36
+ ]
37
+ })
38
+ },
39
+ {
40
+ description: "restrict push to the main branch, except for the admins group",
41
+ example: yaml__default.default.stringify({
42
+ steps: [
43
+ {
44
+ id: "restrictPushToFeatureBranches",
45
+ action: "bitbucketCloud:branchRestriction:create",
46
+ name: "Create Bitbucket Cloud branch restriction by branch type",
47
+ input: {
48
+ repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
49
+ kind: "push",
50
+ groups: [
51
+ {
52
+ slug: "admins"
53
+ }
54
+ ]
55
+ }
56
+ }
57
+ ]
58
+ })
59
+ },
60
+ {
61
+ description: "require passing builds to merge to branches matching a pattern test-feature/*",
62
+ example: yaml__default.default.stringify({
63
+ steps: [
64
+ {
65
+ id: "requirePassingBuildsToMergeByPattern",
66
+ action: "bitbucketCloud:branchRestriction:create",
67
+ name: "Create Bitbucket Cloud require passing build to merge to branches matching a pattern",
68
+ input: {
69
+ repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
70
+ kind: "require_passing_builds_to_merge",
71
+ branchMatchKind: "glob",
72
+ pattern: "test-feature/*"
73
+ }
74
+ }
75
+ ]
76
+ })
77
+ },
78
+ {
79
+ description: "require approvals to merge to branches matching a pattern test-feature/*",
80
+ example: yaml__default.default.stringify({
81
+ steps: [
82
+ {
83
+ id: "requireApprovalsToMergeByPattern",
84
+ action: "bitbucketCloud:branchRestriction:create",
85
+ name: "Create Bitbucket Cloud require approvals to merge branch restriction",
86
+ input: {
87
+ repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
88
+ kind: "require_approvals_to_merge",
89
+ branchMatchKind: "glob",
90
+ pattern: "test-feature/*"
91
+ }
92
+ }
93
+ ]
94
+ })
95
+ }
96
+ ];
97
+
98
+ exports.examples = examples;
99
+ //# sourceMappingURL=bitbucketCloudBranchRestriction.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucketCloudBranchRestriction.examples.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'restrict push to the main branch, except for alice, bob, and the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'createBranchRestriction',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n users: [\n {\n uuid: '{a-b-c-d}',\n },\n {\n uuid: '{e-f-g-h}',\n },\n ],\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'restrict push to the main branch, except for the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'restrictPushToFeatureBranches',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction by branch type',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'require passing builds to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requirePassingBuildsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require passing build to merge to branches matching a pattern',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_passing_builds_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n {\n description:\n 'require approvals to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requireApprovalsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require approvals to merge branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_approvals_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,yBAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,2CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,MAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL;AAAA,gBACE,IAAM,EAAA;AAAA,eACR;AAAA,cACA;AAAA,gBACE,IAAM,EAAA;AAAA;AACR,aACF;AAAA,YACA,MAAQ,EAAA;AAAA,cACN;AAAA,gBACE,IAAM,EAAA;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,+BAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,0DAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,MAAA;AAAA,YACN,MAAQ,EAAA;AAAA,cACN;AAAA,gBACE,IAAM,EAAA;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,sCAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,sFAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,iCAAA;AAAA,YACN,eAAiB,EAAA,MAAA;AAAA,YACjB,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,kCAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,sEAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,4BAAA;AAAA,YACN,eAAiB,EAAA,MAAA;AAAA,YACjB,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -31,7 +31,7 @@ const createBitbucketPipelinesRunAction = (options) => {
31
31
  type: "number"
32
32
  },
33
33
  repoUrl: {
34
- title: "A URL to the pipeline repositry",
34
+ title: "A URL to the pipeline repository",
35
35
  type: "string"
36
36
  },
37
37
  repoContentsUrl: {
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudPipelinesRun.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { examples } from './bitbucketCloudPipelinesRun.examples';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as inputProps from './inputProperties';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getAuthorizationHeader } from './helpers';\n\nconst id = 'bitbucket:pipelines:run';\n/**\n * Creates a new action that triggers a run of a bitbucket pipeline\n *\n * @public\n */\nexport const createBitbucketPipelinesRunAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<{\n workspace: string;\n repo_slug: string;\n body?: object;\n token?: string;\n }>({\n id,\n description: 'Run a bitbucket cloud pipeline',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['workspace', 'repo_slug'],\n properties: {\n workspace: inputProps.workspace,\n repo_slug: inputProps.repo_slug,\n body: inputProps.pipelinesRunBody,\n token: inputProps.token,\n },\n },\n output: {\n type: 'object',\n properties: {\n buildNumber: {\n title: 'Build number',\n type: 'number',\n },\n repoUrl: {\n title: 'A URL to the pipeline repositry',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the pipeline',\n type: 'string',\n },\n },\n },\n },\n supportsDryRun: false,\n async handler(ctx) {\n const { workspace, repo_slug, body, token } = ctx.input;\n const host = 'bitbucket.org';\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n\n const authorization = getAuthorizationHeader(\n token ? { token } : integrationConfig!.config,\n );\n let response: Response;\n try {\n response = await fetch(\n `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,\n {\n method: 'POST',\n headers: {\n Authorization: authorization,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body) ?? {},\n },\n );\n } catch (e) {\n throw new Error(`Unable to run pipeline, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to run pipeline, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const responseObject = await response.json();\n\n ctx.output('buildNumber', responseObject.build_number);\n ctx.output('repoUrl', responseObject.repository.links.html.href);\n ctx.output(\n 'pipelinesUrl',\n `${responseObject.repository.links.html.href}/pipelines`,\n );\n },\n });\n};\n"],"names":["createTemplateAction","examples","inputProps.workspace","inputProps.repo_slug","inputProps.pipelinesRunBody","inputProps.token","getAuthorizationHeader"],"mappings":";;;;;;;AAsBA,MAAM,EAAK,GAAA,yBAAA;AAME,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAKJ,CAAA;AAAA,IACD,EAAA;AAAA,IACA,WAAa,EAAA,gCAAA;AAAA,cACbC,4CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,WAAA,EAAa,WAAW,CAAA;AAAA,QACnC,UAAY,EAAA;AAAA,UACV,WAAWC,yBAAW;AAAA,UACtB,WAAWC,yBAAW;AAAA,UACtB,MAAMC,gCAAW;AAAA,UACjB,OAAOC;AAAW;AACpB,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,cAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,iCAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,eAAiB,EAAA;AAAA,YACf,KAAO,EAAA,uBAAA;AAAA,YACP,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACF;AAAA,IACA,cAAgB,EAAA,KAAA;AAAA,IAChB,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,SAAW,EAAA,SAAA,EAAW,IAAM,EAAA,KAAA,KAAU,GAAI,CAAA,KAAA;AAClD,MAAA,MAAM,IAAO,GAAA,eAAA;AACb,MAAA,MAAM,iBAAoB,GAAA,YAAA,CAAa,cAAe,CA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,CAAA,UAAA;AAAA,OAC9C;AAAA;AACF,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"bitbucketCloudPipelinesRun.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { examples } from './bitbucketCloudPipelinesRun.examples';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as inputProps from './inputProperties';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getAuthorizationHeader } from './helpers';\n\nconst id = 'bitbucket:pipelines:run';\n/**\n * Creates a new action that triggers a run of a bitbucket pipeline\n *\n * @public\n */\nexport const createBitbucketPipelinesRunAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<\n {\n workspace: string;\n repo_slug: string;\n body?: object;\n token?: string;\n },\n {\n buildNumber: number;\n repoUrl: string;\n pipelinesUrl: string;\n }\n >({\n id,\n description: 'Run a bitbucket cloud pipeline',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['workspace', 'repo_slug'],\n properties: {\n workspace: inputProps.workspace,\n repo_slug: inputProps.repo_slug,\n body: inputProps.pipelinesRunBody,\n token: inputProps.token,\n },\n },\n output: {\n type: 'object',\n properties: {\n buildNumber: {\n title: 'Build number',\n type: 'number',\n },\n repoUrl: {\n title: 'A URL to the pipeline repository',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the pipeline',\n type: 'string',\n },\n },\n },\n },\n supportsDryRun: false,\n async handler(ctx) {\n const { workspace, repo_slug, body, token } = ctx.input;\n const host = 'bitbucket.org';\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n\n const authorization = getAuthorizationHeader(\n token ? { token } : integrationConfig!.config,\n );\n let response: Response;\n try {\n response = await fetch(\n `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,\n {\n method: 'POST',\n headers: {\n Authorization: authorization,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body) ?? {},\n },\n );\n } catch (e) {\n throw new Error(`Unable to run pipeline, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to run pipeline, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const responseObject = await response.json();\n\n ctx.output('buildNumber', responseObject.build_number);\n ctx.output('repoUrl', responseObject.repository.links.html.href);\n ctx.output(\n 'pipelinesUrl',\n `${responseObject.repository.links.html.href}/pipelines`,\n );\n },\n });\n};\n"],"names":["createTemplateAction","examples","inputProps.workspace","inputProps.repo_slug","inputProps.pipelinesRunBody","inputProps.token","getAuthorizationHeader"],"mappings":";;;;;;;AAsBA,MAAM,EAAK,GAAA,yBAAA;AAME,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAYL,CAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAa,EAAA,gCAAA;AAAA,cACbC,4CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,WAAA,EAAa,WAAW,CAAA;AAAA,QACnC,UAAY,EAAA;AAAA,UACV,WAAWC,yBAAW;AAAA,UACtB,WAAWC,yBAAW;AAAA,UACtB,MAAMC,gCAAW;AAAA,UACjB,OAAOC;AAAW;AACpB,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,QAAA;AAAA,QACN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B,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,wBAAA,EAA2B,QAAS,CAAA,MAAM,CACxC,CAAA,EAAA,QAAA,CAAS,UACX,CAAK,EAAA,EAAA,MAAM,QAAS,CAAA,IAAA,EAAM,CAAA;AAAA,SAC5B;AAAA;AAGF,MAAM,MAAA,cAAA,GAAiB,MAAM,QAAA,CAAS,IAAK,EAAA;AAE3C,MAAI,GAAA,CAAA,MAAA,CAAO,aAAe,EAAA,cAAA,CAAe,YAAY,CAAA;AACrD,MAAA,GAAA,CAAI,OAAO,SAAW,EAAA,cAAA,CAAe,UAAW,CAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAC/D,MAAI,GAAA,CAAA,MAAA;AAAA,QACF,cAAA;AAAA,QACA,CAAG,EAAA,cAAA,CAAe,UAAW,CAAA,KAAA,CAAM,KAAK,IAAI,CAAA,UAAA;AAAA,OAC9C;AAAA;AACF,GACD,CAAA;AACH;;;;"}
@@ -1,5 +1,26 @@
1
1
  'use strict';
2
2
 
3
+ var bitbucket = require('bitbucket');
4
+
5
+ const getBitbucketClient = (config) => {
6
+ if (config.username && config.appPassword) {
7
+ return new bitbucket.Bitbucket({
8
+ auth: {
9
+ username: config.username,
10
+ password: config.appPassword
11
+ }
12
+ });
13
+ } else if (config.token) {
14
+ return new bitbucket.Bitbucket({
15
+ auth: {
16
+ token: config.token
17
+ }
18
+ });
19
+ }
20
+ throw new Error(
21
+ `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`
22
+ );
23
+ };
3
24
  const getAuthorizationHeader = (config) => {
4
25
  if (config.username && config.appPassword) {
5
26
  const buffer = Buffer.from(
@@ -17,4 +38,5 @@ const getAuthorizationHeader = (config) => {
17
38
  };
18
39
 
19
40
  exports.getAuthorizationHeader = getAuthorizationHeader;
41
+ exports.getBitbucketClient = getBitbucketClient;
20
42
  //# sourceMappingURL=helpers.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n"],"names":[],"mappings":";;AAgBa,MAAA,sBAAA,GAAyB,CAAC,MAIjC,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AAEA,IAAA,OAAO,CAAS,MAAA,EAAA,MAAA,CAAO,QAAS,CAAA,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG3C,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAO,OAAA,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA;AAAA;AAG/B,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Bitbucket } from 'bitbucket';\n\nexport const getBitbucketClient = (config: {\n token?: string;\n username?: string;\n appPassword?: string;\n}) => {\n if (config.username && config.appPassword) {\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.appPassword,\n },\n });\n } else if (config.token) {\n return new Bitbucket({\n auth: {\n token: config.token,\n },\n });\n }\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n"],"names":["Bitbucket"],"mappings":";;;;AAkBa,MAAA,kBAAA,GAAqB,CAAC,MAI7B,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,OAAO,IAAIA,mBAAU,CAAA;AAAA,MACnB,IAAM,EAAA;AAAA,QACJ,UAAU,MAAO,CAAA,QAAA;AAAA,QACjB,UAAU,MAAO,CAAA;AAAA;AACnB,KACD,CAAA;AAAA,GACH,MAAA,IAAW,OAAO,KAAO,EAAA;AACvB,IAAA,OAAO,IAAIA,mBAAU,CAAA;AAAA,MACnB,IAAM,EAAA;AAAA,QACJ,OAAO,MAAO,CAAA;AAAA;AAChB,KACD,CAAA;AAAA;AAEH,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;AAEa,MAAA,sBAAA,GAAyB,CAAC,MAIjC,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AAEA,IAAA,OAAO,CAAS,MAAA,EAAA,MAAA,CAAO,QAAS,CAAA,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG3C,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAO,OAAA,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA;AAAA;AAG/B,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;;;;;"}
@@ -1,5 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const repoUrl = {
4
+ title: "Repository Location",
5
+ description: `Accepts the format 'bitbucket.org?repo=reponame&workspace=workspace&project=project' where 'reponame' is the new repository name`,
6
+ type: "string"
7
+ };
3
8
  const workspace = {
4
9
  title: "Workspace",
5
10
  description: `The workspace name`,
@@ -123,9 +128,95 @@ const pipelinesRunBody = {
123
128
  }
124
129
  }
125
130
  };
131
+ const restriction = {
132
+ kind: {
133
+ title: "kind",
134
+ description: "The kind of restriction.",
135
+ type: "string",
136
+ enum: [
137
+ "push",
138
+ "force",
139
+ "delete",
140
+ "restrict_merges",
141
+ "require_tasks_to_be_completed",
142
+ "require_approvals_to_merge",
143
+ "require_default_reviewer_approvals_to_merge",
144
+ "require_no_changes_requested",
145
+ "require_passing_builds_to_merge",
146
+ "require_commits_behind",
147
+ "reset_pullrequest_approvals_on_change",
148
+ "smart_reset_pullrequest_approvals",
149
+ "reset_pullrequest_changes_requested_on_change",
150
+ "require_all_dependencies_merged",
151
+ "enforce_merge_checks",
152
+ "allow_auto_merge_when_builds_pass"
153
+ ]
154
+ },
155
+ branchMatchKind: {
156
+ title: "branch_match_kind",
157
+ description: "The branch match kind.",
158
+ type: "string",
159
+ enum: ["glob", "branching_model"]
160
+ },
161
+ branchType: {
162
+ title: "branch_type",
163
+ description: "The branch type. When branchMatchKind is set to branching_model, this field is required.",
164
+ type: "string",
165
+ enum: [
166
+ "feature",
167
+ "bugfix",
168
+ "release",
169
+ "hotfix",
170
+ "development",
171
+ "production"
172
+ ]
173
+ },
174
+ pattern: {
175
+ title: "pattern",
176
+ description: "The pattern to match branches against. This field is required when branchMatchKind is set to glob.",
177
+ type: "string"
178
+ },
179
+ value: {
180
+ title: "value",
181
+ description: "The value of the restriction. This field is required when kind is one of require_approvals_to_merge / require_default_reviewer_approvals_to_merge / require_passing_builds_to_merge / require_commits_behind.",
182
+ type: "number"
183
+ },
184
+ users: {
185
+ title: "users",
186
+ description: "Names of users that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.",
187
+ type: "array",
188
+ items: {
189
+ type: "object",
190
+ properties: {
191
+ uuid: {
192
+ title: "uuid",
193
+ description: 'The UUID of the user in the format "{a-b-c-d}".',
194
+ type: "string"
195
+ }
196
+ }
197
+ }
198
+ },
199
+ groups: {
200
+ title: "groups",
201
+ description: "Names of groups that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.",
202
+ type: "array",
203
+ items: {
204
+ type: "object",
205
+ properties: {
206
+ slug: {
207
+ title: "slug",
208
+ description: "The name of the group.",
209
+ type: "string"
210
+ }
211
+ }
212
+ }
213
+ }
214
+ };
126
215
 
127
216
  exports.pipelinesRunBody = pipelinesRunBody;
217
+ exports.repoUrl = repoUrl;
128
218
  exports.repo_slug = repo_slug;
219
+ exports.restriction = restriction;
129
220
  exports.token = token;
130
221
  exports.workspace = workspace;
131
222
  //# sourceMappingURL=inputProperties.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst workspace = {\n title: 'Workspace',\n description: `The workspace name`,\n type: 'string',\n};\n\nconst repo_slug = {\n title: 'Repository name',\n description: 'The repository name',\n type: 'string',\n};\n\nconst ref_type = {\n title: 'ref_type',\n type: 'string',\n};\n\nconst type = {\n title: 'type',\n type: 'string',\n};\n\nconst ref_name = {\n title: 'ref_name',\n type: 'string',\n};\nconst source = {\n title: 'source',\n type: 'string',\n};\nconst destination = {\n title: 'destination',\n type: 'string',\n};\nconst hash = {\n title: 'hash',\n type: 'string',\n};\n\nconst pattern = {\n title: 'pattern',\n type: 'string',\n};\n\nconst id = {\n title: 'id',\n type: 'string',\n};\n\nconst key = {\n title: 'key',\n type: 'string',\n};\nconst value = {\n title: 'value',\n type: 'string',\n};\nconst secured = {\n title: 'secured',\n type: 'boolean',\n};\n\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket Cloud',\n};\n\nconst destination_commit = {\n title: 'destination_commit',\n type: 'object',\n properties: {\n hash,\n },\n};\n\nconst commit = {\n title: 'commit',\n type: 'object',\n properties: {\n type,\n hash,\n },\n};\n\nconst selector = {\n title: 'selector',\n type: 'object',\n properties: {\n type,\n pattern,\n },\n};\n\nconst pull_request = {\n title: 'pull_request',\n type: 'object',\n properties: {\n id,\n },\n};\n\nconst pipelinesRunBody = {\n title: 'Request Body',\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n type: 'object',\n properties: {\n target: {\n title: 'target',\n type: 'object',\n properties: {\n ref_type,\n type,\n ref_name,\n source,\n destination,\n destination_commit,\n commit,\n selector,\n pull_request,\n },\n },\n variables: {\n title: 'variables',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key,\n value,\n secured,\n },\n },\n },\n },\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\n"],"names":[],"mappings":";;AAgBA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,WAAA;AAAA,EACP,WAAa,EAAA,CAAA,kBAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,iBAAA;AAAA,EACP,WAAa,EAAA,qBAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,EAAA,UAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,IAAO,GAAA;AAAA,EACX,KAAO,EAAA,MAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,EAAA,UAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AACA,MAAM,MAAS,GAAA;AAAA,EACb,KAAO,EAAA,QAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AACA,MAAM,WAAc,GAAA;AAAA,EAClB,KAAO,EAAA,aAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AACA,MAAM,IAAO,GAAA;AAAA,EACX,KAAO,EAAA,MAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,OAAU,GAAA;AAAA,EACd,KAAO,EAAA,SAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,EAAK,GAAA;AAAA,EACT,KAAO,EAAA,IAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;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,QACA,QAAA;AAAA,QACA,MAAA;AAAA,QACA,WAAA;AAAA,QACA,kBAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,IACA,SAAW,EAAA;AAAA,MACT,KAAO,EAAA,WAAA;AAAA,MACP,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,GAAA;AAAA,UACA,KAAA;AAAA,UACA;AAAA;AACF;AACF;AACF;AAEJ;;;;;;;"}
1
+ {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst repoUrl = {\n title: 'Repository Location',\n description: `Accepts the format 'bitbucket.org?repo=reponame&workspace=workspace&project=project' where 'reponame' is the new repository name`,\n type: 'string',\n};\n\nconst workspace = {\n title: 'Workspace',\n description: `The workspace name`,\n type: 'string',\n};\n\nconst repo_slug = {\n title: 'Repository name',\n description: 'The repository name',\n type: 'string',\n};\n\nconst ref_type = {\n title: 'ref_type',\n type: 'string',\n};\n\nconst type = {\n title: 'type',\n type: 'string',\n};\n\nconst ref_name = {\n title: 'ref_name',\n type: 'string',\n};\nconst source = {\n title: 'source',\n type: 'string',\n};\nconst destination = {\n title: 'destination',\n type: 'string',\n};\nconst hash = {\n title: 'hash',\n type: 'string',\n};\n\nconst pattern = {\n title: 'pattern',\n type: 'string',\n};\n\nconst id = {\n title: 'id',\n type: 'string',\n};\n\nconst key = {\n title: 'key',\n type: 'string',\n};\nconst value = {\n title: 'value',\n type: 'string',\n};\nconst secured = {\n title: 'secured',\n type: 'boolean',\n};\n\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket Cloud',\n};\n\nconst destination_commit = {\n title: 'destination_commit',\n type: 'object',\n properties: {\n hash,\n },\n};\n\nconst commit = {\n title: 'commit',\n type: 'object',\n properties: {\n type,\n hash,\n },\n};\n\nconst selector = {\n title: 'selector',\n type: 'object',\n properties: {\n type,\n pattern,\n },\n};\n\nconst pull_request = {\n title: 'pull_request',\n type: 'object',\n properties: {\n id,\n },\n};\n\nconst pipelinesRunBody = {\n title: 'Request Body',\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n type: 'object',\n properties: {\n target: {\n title: 'target',\n type: 'object',\n properties: {\n ref_type,\n type,\n ref_name,\n source,\n destination,\n destination_commit,\n commit,\n selector,\n pull_request,\n },\n },\n variables: {\n title: 'variables',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key,\n value,\n secured,\n },\n },\n },\n },\n};\n\nconst restriction = {\n kind: {\n title: 'kind',\n description: 'The kind of restriction.',\n type: 'string',\n enum: [\n 'push',\n 'force',\n 'delete',\n 'restrict_merges',\n 'require_tasks_to_be_completed',\n 'require_approvals_to_merge',\n 'require_default_reviewer_approvals_to_merge',\n 'require_no_changes_requested',\n 'require_passing_builds_to_merge',\n 'require_commits_behind',\n 'reset_pullrequest_approvals_on_change',\n 'smart_reset_pullrequest_approvals',\n 'reset_pullrequest_changes_requested_on_change',\n 'require_all_dependencies_merged',\n 'enforce_merge_checks',\n 'allow_auto_merge_when_builds_pass',\n ],\n },\n branchMatchKind: {\n title: 'branch_match_kind',\n description: 'The branch match kind.',\n type: 'string',\n enum: ['glob', 'branching_model'],\n },\n branchType: {\n title: 'branch_type',\n description:\n 'The branch type. When branchMatchKind is set to branching_model, this field is required.',\n type: 'string',\n enum: [\n 'feature',\n 'bugfix',\n 'release',\n 'hotfix',\n 'development',\n 'production',\n ],\n },\n pattern: {\n title: 'pattern',\n description:\n 'The pattern to match branches against. This field is required when branchMatchKind is set to glob.',\n type: 'string',\n },\n value: {\n title: 'value',\n description:\n 'The value of the restriction. This field is required when kind is one of require_approvals_to_merge / require_default_reviewer_approvals_to_merge / require_passing_builds_to_merge / require_commits_behind.',\n type: 'number',\n },\n users: {\n title: 'users',\n description:\n 'Names of users that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n uuid: {\n title: 'uuid',\n description: 'The UUID of the user in the format \"{a-b-c-d}\".',\n type: 'string',\n },\n },\n },\n },\n groups: {\n title: 'groups',\n description:\n 'Names of groups that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n slug: {\n title: 'slug',\n description: 'The name of the group.',\n type: 'string',\n },\n },\n },\n },\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\nexport { repoUrl, restriction };\n"],"names":[],"mappings":";;AAgBA,MAAM,OAAU,GAAA;AAAA,EACd,KAAO,EAAA,qBAAA;AAAA,EACP,WAAa,EAAA,CAAA,gIAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,WAAA;AAAA,EACP,WAAa,EAAA,CAAA,kBAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,iBAAA;AAAA,EACP,WAAa,EAAA,qBAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,EAAA,UAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,IAAO,GAAA;AAAA,EACX,KAAO,EAAA,MAAA;AAAA,EACP,IAAM,EAAA;AACR,CAAA;AAEA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,E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,KAAO,EAAA,MAAA;AAAA,UACP,WAAa,EAAA,wBAAA;AAAA,UACb,IAAM,EAAA;AAAA;AACR;AACF;AACF;AAEJ;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -14,13 +14,14 @@ declare function createPublishBitbucketCloudAction(options: {
14
14
  config: Config;
15
15
  }): _backstage_plugin_scaffolder_node.TemplateAction<{
16
16
  repoUrl: string;
17
- description?: string | undefined;
18
- defaultBranch?: string | undefined;
19
- repoVisibility?: "private" | "public" | undefined;
20
- gitCommitMessage?: string | undefined;
21
- sourcePath?: string | undefined;
22
- token?: string | undefined;
23
- }, _backstage_types.JsonObject>;
17
+ description?: string;
18
+ defaultBranch?: string;
19
+ repoVisibility?: "private" | "public";
20
+ gitCommitMessage?: string;
21
+ sourcePath?: string;
22
+ token?: string;
23
+ signCommit?: boolean;
24
+ }, _backstage_types.JsonObject, "v1">;
24
25
 
25
26
  /**
26
27
  * Creates a new action that triggers a run of a bitbucket pipeline
@@ -32,9 +33,13 @@ declare const createBitbucketPipelinesRunAction: (options: {
32
33
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
33
34
  workspace: string;
34
35
  repo_slug: string;
35
- body?: object | undefined;
36
- token?: string | undefined;
37
- }, _backstage_types.JsonObject>;
36
+ body?: object;
37
+ token?: string;
38
+ }, {
39
+ buildNumber: number;
40
+ repoUrl: string;
41
+ pipelinesUrl: string;
42
+ }, "v1">;
38
43
 
39
44
  /**
40
45
  * Creates a Bitbucket Cloud Pull Request action.
@@ -46,13 +51,13 @@ declare function createPublishBitbucketCloudPullRequestAction(options: {
46
51
  }): _backstage_plugin_scaffolder_node.TemplateAction<{
47
52
  repoUrl: string;
48
53
  title: string;
49
- description?: string | undefined;
50
- targetBranch?: string | undefined;
54
+ description?: string;
55
+ targetBranch?: string;
51
56
  sourceBranch: string;
52
- token?: string | undefined;
53
- gitAuthorName?: string | undefined;
54
- gitAuthorEmail?: string | undefined;
55
- }, _backstage_types.JsonObject>;
57
+ token?: string;
58
+ gitAuthorName?: string;
59
+ gitAuthorEmail?: string;
60
+ }, _backstage_types.JsonObject, "v1">;
56
61
 
57
62
  /**
58
63
  * @public
@@ -2,6 +2,7 @@
2
2
 
3
3
  var backendPluginApi = require('@backstage/backend-plugin-api');
4
4
  var alpha = require('@backstage/plugin-scaffolder-node/alpha');
5
+ var bitbucketCloudBranchRestriction = require('./actions/bitbucketCloudBranchRestriction.cjs.js');
5
6
  var bitbucketCloud = require('./actions/bitbucketCloud.cjs.js');
6
7
  var bitbucketCloudPipelinesRun = require('./actions/bitbucketCloudPipelinesRun.cjs.js');
7
8
  var bitbucketCloudPullRequest = require('./actions/bitbucketCloudPullRequest.cjs.js');
@@ -26,6 +27,9 @@ const bitbucketCloudModule = backendPluginApi.createBackendModule({
26
27
  bitbucketCloudPullRequest.createPublishBitbucketCloudPullRequestAction({
27
28
  integrations,
28
29
  config
30
+ }),
31
+ bitbucketCloudBranchRestriction.createBitbucketCloudBranchRestrictionAction({
32
+ integrations
29
33
  })
30
34
  );
31
35
  autocomplete$1.addAutocompleteProvider({
@@ -1 +1 @@
1
- {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createBitbucketPipelinesRunAction,\n createPublishBitbucketCloudAction,\n createPublishBitbucketCloudPullRequestAction,\n} from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { handleAutocompleteRequest } from './autocomplete/autocomplete';\n\n/**\n * @public\n * The Bitbucket Cloud Module for the Scaffolder Backend\n */\nexport const bitbucketCloudModule = createBackendModule({\n moduleId: 'bitbucketCloud',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config, autocomplete }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createPublishBitbucketCloudAction({ integrations, config }),\n createBitbucketPipelinesRunAction({ integrations }),\n createPublishBitbucketCloudPullRequestAction({\n integrations,\n config,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'bitbucket-cloud',\n handler: handleAutocompleteRequest,\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createPublishBitbucketCloudAction","createBitbucketPipelinesRunAction","createPublishBitbucketCloudPullRequestAction","handleAutocompleteRequest"],"mappings":";;;;;;;;;;AAmCO,MAAM,uBAAuBA,oCAAoB,CAAA;AAAA,EACtD,QAAU,EAAA,gBAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,YAAc,EAAAC,0CAAA;AAAA,QACd,QAAQC,6BAAa,CAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,UAAY,EAAA,MAAA,gBAAQC,gBAAgB,EAAA;AAC/C,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,gDAAkC,CAAA,EAAE,YAAc,EAAA,MAAA,EAAQ,CAAA;AAAA,UAC1DC,4DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,sEAA6C,CAAA;AAAA,YAC3C,YAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAEA,QAAAJ,cAAA,CAAa,uBAAwB,CAAA;AAAA,UACnC,EAAI,EAAA,iBAAA;AAAA,UACJ,OAAS,EAAAK;AAAA,SACV,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport { createBitbucketCloudBranchRestrictionAction } from './actions/bitbucketCloudBranchRestriction';\nimport {\n createBitbucketPipelinesRunAction,\n createPublishBitbucketCloudAction,\n createPublishBitbucketCloudPullRequestAction,\n} from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { handleAutocompleteRequest } from './autocomplete/autocomplete';\n\n/**\n * @public\n * The Bitbucket Cloud Module for the Scaffolder Backend\n */\nexport const bitbucketCloudModule = createBackendModule({\n moduleId: 'bitbucketCloud',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config, autocomplete }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createPublishBitbucketCloudAction({ integrations, config }),\n createBitbucketPipelinesRunAction({ integrations }),\n createPublishBitbucketCloudPullRequestAction({\n integrations,\n config,\n }),\n createBitbucketCloudBranchRestrictionAction({\n integrations,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'bitbucket-cloud',\n handler: handleAutocompleteRequest,\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createPublishBitbucketCloudAction","createBitbucketPipelinesRunAction","createPublishBitbucketCloudPullRequestAction","createBitbucketCloudBranchRestrictionAction","handleAutocompleteRequest"],"mappings":";;;;;;;;;;;AAoCO,MAAM,uBAAuBA,oCAAoB,CAAA;AAAA,EACtD,QAAU,EAAA,gBAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,YAAc,EAAAC,0CAAA;AAAA,QACd,QAAQC,6BAAa,CAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,UAAY,EAAA,MAAA,gBAAQC,gBAAgB,EAAA;AAC/C,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,gDAAkC,CAAA,EAAE,YAAc,EAAA,MAAA,EAAQ,CAAA;AAAA,UAC1DC,4DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,sEAA6C,CAAA;AAAA,YAC3C,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,2EAA4C,CAAA;AAAA,YAC1C;AAAA,WACD;AAAA,SACH;AAEA,QAAAL,cAAA,CAAa,uBAAwB,CAAA;AAAA,UACnC,EAAI,EAAA,iBAAA;AAAA,UACJ,OAAS,EAAAM;AAAA,SACV,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud",
3
- "version": "0.2.7-next.1",
3
+ "version": "0.2.7",
4
4
  "description": "The Bitbucket Cloud module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -30,13 +30,6 @@
30
30
  },
31
31
  "main": "./dist/index.cjs.js",
32
32
  "types": "./dist/index.d.ts",
33
- "typesVersions": {
34
- "*": {
35
- "index": [
36
- "dist/index.d.ts"
37
- ]
38
- }
39
- },
40
33
  "files": [
41
34
  "dist"
42
35
  ],
@@ -50,19 +43,20 @@
50
43
  "test": "backstage-cli package test"
51
44
  },
52
45
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.2.1-next.1",
54
- "@backstage/config": "1.3.2",
55
- "@backstage/errors": "1.2.7",
56
- "@backstage/integration": "1.16.1",
57
- "@backstage/plugin-bitbucket-cloud-common": "0.2.27",
58
- "@backstage/plugin-scaffolder-node": "0.7.1-next.1",
46
+ "@backstage/backend-plugin-api": "^1.2.1",
47
+ "@backstage/config": "^1.3.2",
48
+ "@backstage/errors": "^1.2.7",
49
+ "@backstage/integration": "^1.16.2",
50
+ "@backstage/plugin-bitbucket-cloud-common": "^0.2.28",
51
+ "@backstage/plugin-scaffolder-node": "^0.8.0",
52
+ "bitbucket": "^2.12.0",
59
53
  "fs-extra": "^11.2.0",
60
54
  "yaml": "^2.0.0"
61
55
  },
62
56
  "devDependencies": {
63
- "@backstage/backend-test-utils": "1.3.1-next.1",
64
- "@backstage/cli": "0.30.1-next.0",
65
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.20-next.1",
57
+ "@backstage/backend-test-utils": "^1.3.1",
58
+ "@backstage/cli": "^0.31.0",
59
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.2.0",
66
60
  "msw": "^1.0.0"
67
61
  }
68
62
  }