@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.2.1-next.1 → 0.2.1-next.2
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 +12 -0
- package/dist/actions/bitbucketCloud.cjs.js +205 -0
- package/dist/actions/bitbucketCloud.cjs.js.map +1 -0
- package/dist/actions/bitbucketCloud.examples.cjs.js +127 -0
- package/dist/actions/bitbucketCloud.examples.cjs.js.map +1 -0
- package/dist/actions/bitbucketCloudPipelinesRun.cjs.js +91 -0
- package/dist/actions/bitbucketCloudPipelinesRun.cjs.js.map +1 -0
- package/dist/actions/bitbucketCloudPipelinesRun.examples.cjs.js +193 -0
- package/dist/actions/bitbucketCloudPipelinesRun.examples.cjs.js.map +1 -0
- package/dist/actions/bitbucketCloudPullRequest.cjs.js +347 -0
- package/dist/actions/bitbucketCloudPullRequest.cjs.js.map +1 -0
- package/dist/actions/bitbucketCloudPullRequest.examples.cjs.js +106 -0
- package/dist/actions/bitbucketCloudPullRequest.examples.cjs.js.map +1 -0
- package/dist/actions/helpers.cjs.js +20 -0
- package/dist/actions/helpers.cjs.js.map +1 -0
- package/dist/actions/inputProperties.cjs.js +131 -0
- package/dist/actions/inputProperties.cjs.js.map +1 -0
- package/dist/autocomplete/autocomplete.cjs.js +67 -0
- package/dist/autocomplete/autocomplete.cjs.js.map +1 -0
- package/dist/index.cjs.js +8 -1241
- package/dist/index.cjs.js.map +1 -1
- package/dist/module.cjs.js +41 -0
- package/dist/module.cjs.js.map +1 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-bitbucket-cloud
|
|
2
2
|
|
|
3
|
+
## 0.2.1-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/integration@1.15.1-next.1
|
|
9
|
+
- @backstage/plugin-scaffolder-node@0.5.0-next.2
|
|
10
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
11
|
+
- @backstage/config@1.2.0
|
|
12
|
+
- @backstage/errors@1.2.4
|
|
13
|
+
- @backstage/plugin-bitbucket-cloud-common@0.2.24-next.1
|
|
14
|
+
|
|
3
15
|
## 0.2.1-next.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@backstage/errors');
|
|
4
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
5
|
+
var fetch = require('node-fetch');
|
|
6
|
+
var helpers = require('./helpers.cjs.js');
|
|
7
|
+
var bitbucketCloud_examples = require('./bitbucketCloud.examples.cjs.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
12
|
+
|
|
13
|
+
const createRepository = async (opts) => {
|
|
14
|
+
const {
|
|
15
|
+
workspace,
|
|
16
|
+
project,
|
|
17
|
+
repo,
|
|
18
|
+
description,
|
|
19
|
+
repoVisibility,
|
|
20
|
+
mainBranch,
|
|
21
|
+
authorization,
|
|
22
|
+
apiBaseUrl
|
|
23
|
+
} = opts;
|
|
24
|
+
const options = {
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
scm: "git",
|
|
28
|
+
description,
|
|
29
|
+
is_private: repoVisibility === "private",
|
|
30
|
+
project: { key: project }
|
|
31
|
+
}),
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: authorization,
|
|
34
|
+
"Content-Type": "application/json"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await fetch__default.default(
|
|
40
|
+
`${apiBaseUrl}/repositories/${workspace}/${repo}`,
|
|
41
|
+
options
|
|
42
|
+
);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
throw new Error(`Unable to create repository, ${e}`);
|
|
45
|
+
}
|
|
46
|
+
if (response.status !== 200) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Unable to create repository, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const r = await response.json();
|
|
52
|
+
let remoteUrl = "";
|
|
53
|
+
for (const link of r.links.clone) {
|
|
54
|
+
if (link.name === "https") {
|
|
55
|
+
remoteUrl = link.href;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;
|
|
59
|
+
return { remoteUrl, repoContentsUrl };
|
|
60
|
+
};
|
|
61
|
+
function createPublishBitbucketCloudAction(options) {
|
|
62
|
+
const { integrations, config } = options;
|
|
63
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
64
|
+
id: "publish:bitbucketCloud",
|
|
65
|
+
examples: bitbucketCloud_examples.examples,
|
|
66
|
+
description: "Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.",
|
|
67
|
+
schema: {
|
|
68
|
+
input: {
|
|
69
|
+
type: "object",
|
|
70
|
+
required: ["repoUrl"],
|
|
71
|
+
properties: {
|
|
72
|
+
repoUrl: {
|
|
73
|
+
title: "Repository Location",
|
|
74
|
+
type: "string"
|
|
75
|
+
},
|
|
76
|
+
description: {
|
|
77
|
+
title: "Repository Description",
|
|
78
|
+
type: "string"
|
|
79
|
+
},
|
|
80
|
+
repoVisibility: {
|
|
81
|
+
title: "Repository Visibility",
|
|
82
|
+
type: "string",
|
|
83
|
+
enum: ["private", "public"]
|
|
84
|
+
},
|
|
85
|
+
defaultBranch: {
|
|
86
|
+
title: "Default Branch",
|
|
87
|
+
type: "string",
|
|
88
|
+
description: `Sets the default branch on the repository. The default value is 'master'`
|
|
89
|
+
},
|
|
90
|
+
gitCommitMessage: {
|
|
91
|
+
title: "Git Commit Message",
|
|
92
|
+
type: "string",
|
|
93
|
+
description: `Sets the commit message on the repository. The default value is 'initial commit'`
|
|
94
|
+
},
|
|
95
|
+
sourcePath: {
|
|
96
|
+
title: "Source Path",
|
|
97
|
+
description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
|
|
98
|
+
type: "string"
|
|
99
|
+
},
|
|
100
|
+
token: {
|
|
101
|
+
title: "Authentication Token",
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "The token to use for authorization to BitBucket Cloud"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
output: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
remoteUrl: {
|
|
111
|
+
title: "A URL to the repository with the provider",
|
|
112
|
+
type: "string"
|
|
113
|
+
},
|
|
114
|
+
repoContentsUrl: {
|
|
115
|
+
title: "A URL to the root of the repository",
|
|
116
|
+
type: "string"
|
|
117
|
+
},
|
|
118
|
+
commitHash: {
|
|
119
|
+
title: "The git commit hash of the initial commit",
|
|
120
|
+
type: "string"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
async handler(ctx) {
|
|
126
|
+
const {
|
|
127
|
+
repoUrl,
|
|
128
|
+
description,
|
|
129
|
+
defaultBranch = "master",
|
|
130
|
+
gitCommitMessage,
|
|
131
|
+
repoVisibility = "private"
|
|
132
|
+
} = ctx.input;
|
|
133
|
+
const { workspace, project, repo, host } = pluginScaffolderNode.parseRepoUrl(
|
|
134
|
+
repoUrl,
|
|
135
|
+
integrations
|
|
136
|
+
);
|
|
137
|
+
if (!workspace) {
|
|
138
|
+
throw new errors.InputError(
|
|
139
|
+
`Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (!project) {
|
|
143
|
+
throw new errors.InputError(
|
|
144
|
+
`Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const integrationConfig = integrations.bitbucketCloud.byHost(host);
|
|
148
|
+
if (!integrationConfig) {
|
|
149
|
+
throw new errors.InputError(
|
|
150
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const authorization = helpers.getAuthorizationHeader(
|
|
154
|
+
ctx.input.token ? { token: ctx.input.token } : integrationConfig.config
|
|
155
|
+
);
|
|
156
|
+
const apiBaseUrl = integrationConfig.config.apiBaseUrl;
|
|
157
|
+
const { remoteUrl, repoContentsUrl } = await createRepository({
|
|
158
|
+
authorization,
|
|
159
|
+
workspace: workspace || "",
|
|
160
|
+
project,
|
|
161
|
+
repo,
|
|
162
|
+
repoVisibility,
|
|
163
|
+
mainBranch: defaultBranch,
|
|
164
|
+
description,
|
|
165
|
+
apiBaseUrl
|
|
166
|
+
});
|
|
167
|
+
const gitAuthorInfo = {
|
|
168
|
+
name: config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
169
|
+
email: config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
170
|
+
};
|
|
171
|
+
let auth;
|
|
172
|
+
if (ctx.input.token) {
|
|
173
|
+
auth = {
|
|
174
|
+
username: "x-token-auth",
|
|
175
|
+
password: ctx.input.token
|
|
176
|
+
};
|
|
177
|
+
} else {
|
|
178
|
+
if (!integrationConfig.config.username || !integrationConfig.config.appPassword) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
"Credentials for Bitbucket Cloud integration required for this action."
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
auth = {
|
|
184
|
+
username: integrationConfig.config.username,
|
|
185
|
+
password: integrationConfig.config.appPassword
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const commitResult = await pluginScaffolderNode.initRepoAndPush({
|
|
189
|
+
dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
|
|
190
|
+
remoteUrl,
|
|
191
|
+
auth,
|
|
192
|
+
defaultBranch,
|
|
193
|
+
logger: ctx.logger,
|
|
194
|
+
commitMessage: gitCommitMessage || config.getOptionalString("scaffolder.defaultCommitMessage"),
|
|
195
|
+
gitAuthorInfo
|
|
196
|
+
});
|
|
197
|
+
ctx.output("commitHash", commitResult?.commitHash);
|
|
198
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
199
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
exports.createPublishBitbucketCloudAction = createPublishBitbucketCloudAction;
|
|
205
|
+
//# sourceMappingURL=bitbucketCloud.cjs.js.map
|
|
@@ -0,0 +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';\nimport fetch, { Response, RequestInit } from 'node-fetch';\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":["fetch","createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;;;;;AA8BA,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,UAAA;AAAA,GACE,GAAA,IAAA,CAAA;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,EAAA;AAAA,KACzB,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,aAAe,EAAA,aAAA;AAAA,MACf,cAAgB,EAAA,kBAAA;AAAA,KAClB;AAAA,GACF,CAAA;AAEA,EAAI,IAAA,QAAA,CAAA;AACJ,EAAI,IAAA;AACF,IA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AAAA,QACA,aAAA;AAAA,QACA,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,aACE,EAAA,gBAAA,IACA,MAAO,CAAA,iBAAA,CAAkB,iCAAiC,CAAA;AAAA,QAC5D,aAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,KAC/C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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: "Initializes a git repository with the content in the workspace, and publishes it to Bitbucket Cloud with the default configuration.",
|
|
12
|
+
example: yaml__default.default.stringify({
|
|
13
|
+
steps: [
|
|
14
|
+
{
|
|
15
|
+
id: "publish",
|
|
16
|
+
action: "publish:bitbucketCloud",
|
|
17
|
+
name: "Publish to Bitbucket Cloud",
|
|
18
|
+
input: {
|
|
19
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: "Initializes a Bitbucket Cloud repository with a description.",
|
|
27
|
+
example: yaml__default.default.stringify({
|
|
28
|
+
steps: [
|
|
29
|
+
{
|
|
30
|
+
id: "publish",
|
|
31
|
+
action: "publish:bitbucketCloud",
|
|
32
|
+
name: "Publish to Bitbucket Cloud",
|
|
33
|
+
input: {
|
|
34
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
35
|
+
description: "Initialize a git repository"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: "Initializes a Bitbucket Cloud repository with public repo visibility, if not set defaults to private",
|
|
43
|
+
example: yaml__default.default.stringify({
|
|
44
|
+
steps: [
|
|
45
|
+
{
|
|
46
|
+
id: "publish",
|
|
47
|
+
action: "publish:bitbucketCloud",
|
|
48
|
+
name: "Publish to Bitbucket Cloud",
|
|
49
|
+
input: {
|
|
50
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
51
|
+
repoVisibility: "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
description: "Initializes a Bitbucket Cloud repository with a default Branch, if not set defaults to master",
|
|
59
|
+
example: yaml__default.default.stringify({
|
|
60
|
+
steps: [
|
|
61
|
+
{
|
|
62
|
+
id: "publish",
|
|
63
|
+
action: "publish:bitbucketCloud",
|
|
64
|
+
name: "Publish to Bitbucket Cloud",
|
|
65
|
+
input: {
|
|
66
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
67
|
+
defaultBranch: "main"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository",
|
|
75
|
+
example: yaml__default.default.stringify({
|
|
76
|
+
steps: [
|
|
77
|
+
{
|
|
78
|
+
id: "publish",
|
|
79
|
+
action: "publish:bitbucketCloud",
|
|
80
|
+
name: "Publish to Bitbucket Cloud",
|
|
81
|
+
input: {
|
|
82
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
83
|
+
sourcePath: "./repoRoot"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
description: "Initializes a Bitbucket Cloud repository with a custom authentication token",
|
|
91
|
+
example: yaml__default.default.stringify({
|
|
92
|
+
steps: [
|
|
93
|
+
{
|
|
94
|
+
id: "publish",
|
|
95
|
+
action: "publish:bitbucketCloud",
|
|
96
|
+
name: "Publish to Bitbucket Cloud",
|
|
97
|
+
input: {
|
|
98
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
99
|
+
token: "your-custom-auth-token"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
description: "Initializes a Bitbucket Cloud repository with all proporties being set",
|
|
107
|
+
example: yaml__default.default.stringify({
|
|
108
|
+
steps: [
|
|
109
|
+
{
|
|
110
|
+
id: "publish",
|
|
111
|
+
action: "publish:bitbucketCloud",
|
|
112
|
+
name: "Publish to Bitbucket Cloud",
|
|
113
|
+
input: {
|
|
114
|
+
repoUrl: "bitbucket.org?repo=repo&workspace=workspace&project=project",
|
|
115
|
+
description: "Initialize a git repository",
|
|
116
|
+
repoVisibility: "public",
|
|
117
|
+
defaultBranch: "main",
|
|
118
|
+
token: "your-custom-auth-token"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
exports.examples = examples;
|
|
127
|
+
//# sourceMappingURL=bitbucketCloud.examples.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitbucketCloud.examples.cjs.js","sources":["../../src/actions/bitbucketCloud.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 'Initializes a git repository with the content in the workspace, and publishes it to Bitbucket Cloud with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Bitbucket Cloud repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a default Branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\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 example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n sourcePath: './repoRoot',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a custom authentication token',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with all proporties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n repoVisibility: 'public',\n defaultBranch: 'main',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,qIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,WACJ;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,8DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,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ACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,6EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA,wBAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,wEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,WAAa,EAAA,6BAAA;AAAA,YACb,cAAgB,EAAA,QAAA;AAAA,YAChB,aAAe,EAAA,MAAA;AAAA,YACf,KAAO,EAAA,wBAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bitbucketCloudPipelinesRun_examples = require('./bitbucketCloudPipelinesRun.examples.cjs.js');
|
|
4
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
5
|
+
var fetch = require('node-fetch');
|
|
6
|
+
var inputProperties = require('./inputProperties.cjs.js');
|
|
7
|
+
var helpers = require('./helpers.cjs.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
12
|
+
|
|
13
|
+
const id = "bitbucket:pipelines:run";
|
|
14
|
+
const createBitbucketPipelinesRunAction = (options) => {
|
|
15
|
+
const { integrations } = options;
|
|
16
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
17
|
+
id,
|
|
18
|
+
description: "Run a bitbucket cloud pipeline",
|
|
19
|
+
examples: bitbucketCloudPipelinesRun_examples.examples,
|
|
20
|
+
schema: {
|
|
21
|
+
input: {
|
|
22
|
+
type: "object",
|
|
23
|
+
required: ["workspace", "repo_slug"],
|
|
24
|
+
properties: {
|
|
25
|
+
workspace: inputProperties.workspace,
|
|
26
|
+
repo_slug: inputProperties.repo_slug,
|
|
27
|
+
body: inputProperties.pipelinesRunBody,
|
|
28
|
+
token: inputProperties.token
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
output: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
buildNumber: {
|
|
35
|
+
title: "Build number",
|
|
36
|
+
type: "number"
|
|
37
|
+
},
|
|
38
|
+
repoUrl: {
|
|
39
|
+
title: "A URL to the pipeline repositry",
|
|
40
|
+
type: "string"
|
|
41
|
+
},
|
|
42
|
+
repoContentsUrl: {
|
|
43
|
+
title: "A URL to the pipeline",
|
|
44
|
+
type: "string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
supportsDryRun: false,
|
|
50
|
+
async handler(ctx) {
|
|
51
|
+
const { workspace, repo_slug, body, token } = ctx.input;
|
|
52
|
+
const host = "bitbucket.org";
|
|
53
|
+
const integrationConfig = integrations.bitbucketCloud.byHost(host);
|
|
54
|
+
const authorization = helpers.getAuthorizationHeader(
|
|
55
|
+
token ? { token } : integrationConfig.config
|
|
56
|
+
);
|
|
57
|
+
let response;
|
|
58
|
+
try {
|
|
59
|
+
response = await fetch__default.default(
|
|
60
|
+
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,
|
|
61
|
+
{
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: authorization,
|
|
65
|
+
Accept: "application/json",
|
|
66
|
+
"Content-Type": "application/json"
|
|
67
|
+
},
|
|
68
|
+
body: JSON.stringify(body) ?? {}
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
throw new Error(`Unable to run pipeline, ${e}`);
|
|
73
|
+
}
|
|
74
|
+
if (response.status !== 201) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Unable to run pipeline, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const responseObject = await response.json();
|
|
80
|
+
ctx.output("buildNumber", responseObject.build_number);
|
|
81
|
+
ctx.output("repoUrl", responseObject.repository.links.html.href);
|
|
82
|
+
ctx.output(
|
|
83
|
+
"pipelinesUrl",
|
|
84
|
+
`${responseObject.repository.links.html.href}/pipelines`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
exports.createBitbucketPipelinesRunAction = createBitbucketPipelinesRunAction;
|
|
91
|
+
//# sourceMappingURL=bitbucketCloudPipelinesRun.cjs.js.map
|
|
@@ -0,0 +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 fetch, { Response } from 'node-fetch';\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","fetch"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,EAAK,GAAA,yBAAA,CAAA;AAME,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA,CAAA;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,qBAAW;AAAA,SACpB;AAAA,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,QAAA;AAAA,WACR;AAAA,UACA,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,iCAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,eAAiB,EAAA;AAAA,YACf,KAAO,EAAA,uBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,SACF;AAAA,OACF;AAAA,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,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