@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.2.1-next.0 → 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 +24 -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 +10 -10
|
@@ -0,0 +1,193 @@
|
|
|
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: "Trigger a pipeline for a branch",
|
|
12
|
+
example: yaml__default.default.stringify({
|
|
13
|
+
steps: [
|
|
14
|
+
{
|
|
15
|
+
action: "bitbucket:pipelines:run",
|
|
16
|
+
id: "run-bitbucket-pipeline",
|
|
17
|
+
name: "Run an example bitbucket pipeline",
|
|
18
|
+
input: {
|
|
19
|
+
workspace: "test-workspace",
|
|
20
|
+
repo_slug: "test-repo-slug",
|
|
21
|
+
body: {
|
|
22
|
+
target: {
|
|
23
|
+
ref_type: "branch",
|
|
24
|
+
type: "pipeline_ref_target",
|
|
25
|
+
ref_name: "master"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: "Trigger a pipeline for a commit on a branch",
|
|
35
|
+
example: yaml__default.default.stringify({
|
|
36
|
+
steps: [
|
|
37
|
+
{
|
|
38
|
+
action: "bitbucket:pipelines:run",
|
|
39
|
+
id: "run-bitbucket-pipeline",
|
|
40
|
+
name: "Run an example bitbucket pipeline",
|
|
41
|
+
input: {
|
|
42
|
+
workspace: "test-workspace",
|
|
43
|
+
repo_slug: "test-repo-slug",
|
|
44
|
+
body: {
|
|
45
|
+
target: {
|
|
46
|
+
commit: {
|
|
47
|
+
type: "commit",
|
|
48
|
+
hash: "ce5b7431602f7cbba007062eeb55225c6e18e956"
|
|
49
|
+
},
|
|
50
|
+
ref_type: "branch",
|
|
51
|
+
type: "pipeline_ref_target",
|
|
52
|
+
ref_name: "master"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
description: "Trigger a specific pipeline definition for a commit",
|
|
62
|
+
example: yaml__default.default.stringify({
|
|
63
|
+
steps: [
|
|
64
|
+
{
|
|
65
|
+
action: "bitbucket:pipelines:run",
|
|
66
|
+
id: "run-bitbucket-pipeline",
|
|
67
|
+
name: "Run an example bitbucket pipeline",
|
|
68
|
+
input: {
|
|
69
|
+
workspace: "test-workspace",
|
|
70
|
+
repo_slug: "test-repo-slug",
|
|
71
|
+
body: {
|
|
72
|
+
target: {
|
|
73
|
+
commit: {
|
|
74
|
+
type: "commit",
|
|
75
|
+
hash: "a3c4e02c9a3755eccdc3764e6ea13facdf30f923"
|
|
76
|
+
},
|
|
77
|
+
selector: {
|
|
78
|
+
type: "custom",
|
|
79
|
+
pattern: "Deploy to production"
|
|
80
|
+
},
|
|
81
|
+
type: "pipeline_commit_target"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
description: "Trigger a specific pipeline definition for a commit on a branch or tag",
|
|
91
|
+
example: yaml__default.default.stringify({
|
|
92
|
+
steps: [
|
|
93
|
+
{
|
|
94
|
+
action: "bitbucket:pipelines:run",
|
|
95
|
+
id: "run-bitbucket-pipeline",
|
|
96
|
+
name: "Run an example bitbucket pipeline",
|
|
97
|
+
input: {
|
|
98
|
+
workspace: "test-workspace",
|
|
99
|
+
repo_slug: "test-repo-slug",
|
|
100
|
+
body: {
|
|
101
|
+
target: {
|
|
102
|
+
commit: {
|
|
103
|
+
type: "commit",
|
|
104
|
+
hash: "a3c4e02c9a3755eccdc3764e6ea13facdf30f923"
|
|
105
|
+
},
|
|
106
|
+
selector: {
|
|
107
|
+
type: "custom",
|
|
108
|
+
pattern: "Deploy to production"
|
|
109
|
+
},
|
|
110
|
+
type: "pipeline_ref_target",
|
|
111
|
+
ref_name: "master",
|
|
112
|
+
ref_type: "branch"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
description: "Trigger a custom pipeline with variables",
|
|
122
|
+
example: yaml__default.default.stringify({
|
|
123
|
+
steps: [
|
|
124
|
+
{
|
|
125
|
+
action: "bitbucket:pipelines:run",
|
|
126
|
+
id: "run-bitbucket-pipeline",
|
|
127
|
+
name: "Run an example bitbucket pipeline",
|
|
128
|
+
input: {
|
|
129
|
+
workspace: "test-workspace",
|
|
130
|
+
repo_slug: "test-repo-slug",
|
|
131
|
+
body: {
|
|
132
|
+
target: {
|
|
133
|
+
type: "pipeline_ref_target",
|
|
134
|
+
ref_name: "master",
|
|
135
|
+
ref_type: "branch",
|
|
136
|
+
selector: {
|
|
137
|
+
type: "custom",
|
|
138
|
+
pattern: "Deploy to production"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
variables: [
|
|
142
|
+
{ key: "var1key", value: "var1value", secured: true },
|
|
143
|
+
{
|
|
144
|
+
key: "var2key",
|
|
145
|
+
value: "var2value"
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
description: "Trigger a pull request pipeline",
|
|
156
|
+
example: yaml__default.default.stringify({
|
|
157
|
+
steps: [
|
|
158
|
+
{
|
|
159
|
+
action: "bitbucket:pipelines:run",
|
|
160
|
+
id: "run-bitbucket-pipeline",
|
|
161
|
+
name: "Run an example bitbucket pipeline",
|
|
162
|
+
input: {
|
|
163
|
+
workspace: "test-workspace",
|
|
164
|
+
repo_slug: "test-repo-slug",
|
|
165
|
+
body: {
|
|
166
|
+
target: {
|
|
167
|
+
type: "pipeline_pullrequest_target",
|
|
168
|
+
source: "pull-request-branch",
|
|
169
|
+
destination: "master",
|
|
170
|
+
destination_commit: {
|
|
171
|
+
hash: "9f848b7"
|
|
172
|
+
},
|
|
173
|
+
commit: {
|
|
174
|
+
hash: "1a372fc"
|
|
175
|
+
},
|
|
176
|
+
pull_request: {
|
|
177
|
+
id: "3"
|
|
178
|
+
},
|
|
179
|
+
selector: {
|
|
180
|
+
type: "pull-requests",
|
|
181
|
+
pattern: "**"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
exports.examples = examples;
|
|
193
|
+
//# sourceMappingURL=bitbucketCloudPipelinesRun.examples.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitbucketCloudPipelinesRun.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a pipeline for a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pipeline for a commit on a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'ce5b7431602f7cbba007062eeb55225c6e18e956',\n },\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a specific pipeline definition for a commit',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_commit_target',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Trigger a specific pipeline definition for a commit on a branch or tag',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a custom pipeline with variables',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n },\n variables: [\n { key: 'var1key', value: 'var1value', secured: true },\n {\n key: 'var2key',\n value: 'var2value',\n },\n ],\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pull request pipeline',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_pullrequest_target',\n source: 'pull-request-branch',\n destination: 'master',\n destination_commit: {\n hash: '9f848b7',\n },\n commit: {\n hash: '1a372fc',\n },\n pull_request: {\n id: '3',\n },\n selector: {\n type: 'pull-requests',\n pattern: '**',\n },\n },\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,iCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,EAAI,EAAA,wBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,gBAAA;AAAA,YACX,SAAW,EAAA,gBAAA;AAAA,YACX,IAAM,EAAA;AAAA,cACJ,MAAQ,EAAA;AAAA,gBACN,QAAU,EAAA,QAAA;AAAA,gBACV,IAAM,EAAA,qBAAA;AAAA,gBACN,QAAU,EAAA,QAAA;AAAA,eACZ;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,6CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,EAAI,EAAA,wBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,gBAAA;AAAA,YACX,SAAW,E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AA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,iCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,EAAI,EAAA,wBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,gBAAA;AAAA,YACX,SAAW,EAAA,gBAAA;AAAA,YACX,IAAM,EAAA;AAAA,cACJ,MAAQ,EAAA;AAAA,gBACN,IAAM,EAAA,6BAAA;AAAA,gBACN,MAAQ,EAAA,qBAAA;AAAA,gBACR,WAAa,EAAA,QAAA;AAAA,gBACb,kBAAoB,EAAA;AAAA,kBAClB,IAAM,EAAA,SAAA;AAAA,iBACR;AAAA,gBACA,MAAQ,EAAA;AAAA,kBACN,IAAM,EAAA,SAAA;AAAA,iBACR;AAAA,gBACA,YAAc,EAAA;AAAA,kBACZ,EAAI,EAAA,GAAA;AAAA,iBACN;AAAA,gBACA,QAAU,EAAA;AAAA,kBACR,IAAM,EAAA,eAAA;AAAA,kBACN,OAAS,EAAA,IAAA;AAAA,iBACX;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -0,0 +1,347 @@
|
|
|
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 fs = require('fs-extra');
|
|
7
|
+
var helpers = require('./helpers.cjs.js');
|
|
8
|
+
var bitbucketCloudPullRequest_examples = require('./bitbucketCloudPullRequest.examples.cjs.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
13
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
+
|
|
15
|
+
const createPullRequest = async (opts) => {
|
|
16
|
+
const {
|
|
17
|
+
workspace,
|
|
18
|
+
repo,
|
|
19
|
+
title,
|
|
20
|
+
description,
|
|
21
|
+
targetBranch,
|
|
22
|
+
sourceBranch,
|
|
23
|
+
authorization,
|
|
24
|
+
apiBaseUrl
|
|
25
|
+
} = opts;
|
|
26
|
+
let response;
|
|
27
|
+
const data = {
|
|
28
|
+
method: "POST",
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
title,
|
|
31
|
+
summary: {
|
|
32
|
+
raw: description
|
|
33
|
+
},
|
|
34
|
+
state: "OPEN",
|
|
35
|
+
source: {
|
|
36
|
+
branch: {
|
|
37
|
+
name: sourceBranch
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
destination: {
|
|
41
|
+
branch: {
|
|
42
|
+
name: targetBranch
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: authorization,
|
|
48
|
+
"Content-Type": "application/json"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
response = await fetch__default.default(
|
|
53
|
+
`${apiBaseUrl}/repositories/${workspace}/${repo}/pullrequests`,
|
|
54
|
+
data
|
|
55
|
+
);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
throw new Error(`Unable to create pull-reqeusts, ${e}`);
|
|
58
|
+
}
|
|
59
|
+
if (response.status !== 201) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Unable to create pull requests, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const r = await response.json();
|
|
65
|
+
return r.links.html.href;
|
|
66
|
+
};
|
|
67
|
+
const findBranches = async (opts) => {
|
|
68
|
+
const { workspace, repo, branchName, authorization, apiBaseUrl } = opts;
|
|
69
|
+
let response;
|
|
70
|
+
const options = {
|
|
71
|
+
method: "GET",
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: authorization,
|
|
74
|
+
"Content-Type": "application/json"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
try {
|
|
78
|
+
response = await fetch__default.default(
|
|
79
|
+
`${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches?q=${encodeURIComponent(
|
|
80
|
+
`name = "${branchName}"`
|
|
81
|
+
)}`,
|
|
82
|
+
options
|
|
83
|
+
);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
throw new Error(`Unable to get branches, ${e}`);
|
|
86
|
+
}
|
|
87
|
+
if (response.status !== 200) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Unable to get branches, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
const r = await response.json();
|
|
93
|
+
return r.values[0];
|
|
94
|
+
};
|
|
95
|
+
const createBranch = async (opts) => {
|
|
96
|
+
const {
|
|
97
|
+
workspace,
|
|
98
|
+
repo,
|
|
99
|
+
branchName,
|
|
100
|
+
authorization,
|
|
101
|
+
apiBaseUrl,
|
|
102
|
+
startBranch
|
|
103
|
+
} = opts;
|
|
104
|
+
let response;
|
|
105
|
+
const options = {
|
|
106
|
+
method: "POST",
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
name: branchName,
|
|
109
|
+
target: {
|
|
110
|
+
hash: startBranch
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: authorization,
|
|
115
|
+
"Content-Type": "application/json"
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
try {
|
|
119
|
+
response = await fetch__default.default(
|
|
120
|
+
`${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches`,
|
|
121
|
+
options
|
|
122
|
+
);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
throw new Error(`Unable to create branch, ${e}`);
|
|
125
|
+
}
|
|
126
|
+
if (response.status !== 201) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Unable to create branch, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return await response.json();
|
|
132
|
+
};
|
|
133
|
+
const getDefaultBranch = async (opts) => {
|
|
134
|
+
const { workspace, repo, authorization, apiBaseUrl } = opts;
|
|
135
|
+
let response;
|
|
136
|
+
const options = {
|
|
137
|
+
method: "GET",
|
|
138
|
+
headers: {
|
|
139
|
+
Authorization: authorization,
|
|
140
|
+
"Content-Type": "application/json"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
try {
|
|
144
|
+
response = await fetch__default.default(
|
|
145
|
+
`${apiBaseUrl}/repositories/${workspace}/${repo}`,
|
|
146
|
+
options
|
|
147
|
+
);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
const { mainbranch } = await response.json();
|
|
152
|
+
const defaultBranch = mainbranch.name;
|
|
153
|
+
if (!defaultBranch) {
|
|
154
|
+
throw new Error(`Could not fetch default branch for ${workspace}/${repo}`);
|
|
155
|
+
}
|
|
156
|
+
return defaultBranch;
|
|
157
|
+
};
|
|
158
|
+
function createPublishBitbucketCloudPullRequestAction(options) {
|
|
159
|
+
const { integrations, config } = options;
|
|
160
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
161
|
+
id: "publish:bitbucketCloud:pull-request",
|
|
162
|
+
examples: bitbucketCloudPullRequest_examples.examples,
|
|
163
|
+
schema: {
|
|
164
|
+
input: {
|
|
165
|
+
type: "object",
|
|
166
|
+
required: ["repoUrl", "title", "sourceBranch"],
|
|
167
|
+
properties: {
|
|
168
|
+
repoUrl: {
|
|
169
|
+
title: "Repository Location",
|
|
170
|
+
type: "string"
|
|
171
|
+
},
|
|
172
|
+
title: {
|
|
173
|
+
title: "Pull Request title",
|
|
174
|
+
type: "string",
|
|
175
|
+
description: "The title for the pull request"
|
|
176
|
+
},
|
|
177
|
+
description: {
|
|
178
|
+
title: "Pull Request Description",
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "The description of the pull request"
|
|
181
|
+
},
|
|
182
|
+
targetBranch: {
|
|
183
|
+
title: "Target Branch",
|
|
184
|
+
type: "string",
|
|
185
|
+
description: `Branch of repository to apply changes to. The default value is 'master'`
|
|
186
|
+
},
|
|
187
|
+
sourceBranch: {
|
|
188
|
+
title: "Source Branch",
|
|
189
|
+
type: "string",
|
|
190
|
+
description: "Branch of repository to copy changes from"
|
|
191
|
+
},
|
|
192
|
+
token: {
|
|
193
|
+
title: "Authorization Token",
|
|
194
|
+
type: "string",
|
|
195
|
+
description: "The token to use for authorization to BitBucket Cloud"
|
|
196
|
+
},
|
|
197
|
+
gitAuthorName: {
|
|
198
|
+
title: "Author Name",
|
|
199
|
+
type: "string",
|
|
200
|
+
description: `Sets the author name for the commit. The default value is 'Scaffolder'`
|
|
201
|
+
},
|
|
202
|
+
gitAuthorEmail: {
|
|
203
|
+
title: "Author Email",
|
|
204
|
+
type: "string",
|
|
205
|
+
description: `Sets the author email for the commit.`
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
output: {
|
|
210
|
+
type: "object",
|
|
211
|
+
properties: {
|
|
212
|
+
pullRequestUrl: {
|
|
213
|
+
title: "A URL to the pull request with the provider",
|
|
214
|
+
type: "string"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
async handler(ctx) {
|
|
220
|
+
const {
|
|
221
|
+
repoUrl,
|
|
222
|
+
title,
|
|
223
|
+
description,
|
|
224
|
+
targetBranch,
|
|
225
|
+
sourceBranch,
|
|
226
|
+
gitAuthorName,
|
|
227
|
+
gitAuthorEmail
|
|
228
|
+
} = ctx.input;
|
|
229
|
+
const { workspace, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
230
|
+
if (!workspace) {
|
|
231
|
+
throw new errors.InputError(
|
|
232
|
+
`Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const integrationConfig = integrations.bitbucketCloud.byHost(host);
|
|
236
|
+
if (!integrationConfig) {
|
|
237
|
+
throw new errors.InputError(
|
|
238
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
const authorization = helpers.getAuthorizationHeader(
|
|
242
|
+
ctx.input.token ? { token: ctx.input.token } : integrationConfig.config
|
|
243
|
+
);
|
|
244
|
+
const apiBaseUrl = integrationConfig.config.apiBaseUrl;
|
|
245
|
+
let finalTargetBranch = targetBranch;
|
|
246
|
+
if (!finalTargetBranch) {
|
|
247
|
+
finalTargetBranch = await getDefaultBranch({
|
|
248
|
+
workspace,
|
|
249
|
+
repo,
|
|
250
|
+
authorization,
|
|
251
|
+
apiBaseUrl
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const sourceBranchRef = await findBranches({
|
|
255
|
+
workspace,
|
|
256
|
+
repo,
|
|
257
|
+
branchName: sourceBranch,
|
|
258
|
+
authorization,
|
|
259
|
+
apiBaseUrl
|
|
260
|
+
});
|
|
261
|
+
if (!sourceBranchRef) {
|
|
262
|
+
ctx.logger.info(
|
|
263
|
+
`source branch not found -> creating branch named: ${sourceBranch}`
|
|
264
|
+
);
|
|
265
|
+
await createBranch({
|
|
266
|
+
workspace,
|
|
267
|
+
repo,
|
|
268
|
+
branchName: sourceBranch,
|
|
269
|
+
authorization,
|
|
270
|
+
apiBaseUrl,
|
|
271
|
+
startBranch: finalTargetBranch
|
|
272
|
+
});
|
|
273
|
+
const remoteUrl = `https://${host}/${workspace}/${repo}.git`;
|
|
274
|
+
let auth;
|
|
275
|
+
if (ctx.input.token) {
|
|
276
|
+
auth = {
|
|
277
|
+
username: "x-token-auth",
|
|
278
|
+
password: ctx.input.token
|
|
279
|
+
};
|
|
280
|
+
} else {
|
|
281
|
+
if (!integrationConfig.config.username || !integrationConfig.config.appPassword) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
"Credentials for Bitbucket Cloud integration required for this action."
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
auth = {
|
|
287
|
+
username: integrationConfig.config.username,
|
|
288
|
+
password: integrationConfig.config.appPassword
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const gitAuthorInfo = {
|
|
292
|
+
name: gitAuthorName || config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
293
|
+
email: gitAuthorEmail || config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
294
|
+
};
|
|
295
|
+
const tempDir = await ctx.createTemporaryDirectory();
|
|
296
|
+
const sourceDir = pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, void 0);
|
|
297
|
+
await pluginScaffolderNode.cloneRepo({
|
|
298
|
+
url: remoteUrl,
|
|
299
|
+
dir: tempDir,
|
|
300
|
+
auth,
|
|
301
|
+
logger: ctx.logger,
|
|
302
|
+
ref: sourceBranch
|
|
303
|
+
});
|
|
304
|
+
await pluginScaffolderNode.createBranch({
|
|
305
|
+
dir: tempDir,
|
|
306
|
+
auth,
|
|
307
|
+
logger: ctx.logger,
|
|
308
|
+
ref: sourceBranch
|
|
309
|
+
});
|
|
310
|
+
fs__default.default.cpSync(sourceDir, tempDir, {
|
|
311
|
+
recursive: true,
|
|
312
|
+
filter: (path) => {
|
|
313
|
+
return !(path.indexOf(".git") > -1);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
await pluginScaffolderNode.addFiles({
|
|
317
|
+
dir: tempDir,
|
|
318
|
+
auth,
|
|
319
|
+
logger: ctx.logger,
|
|
320
|
+
filepath: "."
|
|
321
|
+
});
|
|
322
|
+
await pluginScaffolderNode.commitAndPushBranch({
|
|
323
|
+
dir: tempDir,
|
|
324
|
+
auth,
|
|
325
|
+
logger: ctx.logger,
|
|
326
|
+
commitMessage: description ?? config.getOptionalString("scaffolder.defaultCommitMessage") ?? "",
|
|
327
|
+
gitAuthorInfo,
|
|
328
|
+
branch: sourceBranch
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
const pullRequestUrl = await createPullRequest({
|
|
332
|
+
workspace,
|
|
333
|
+
repo,
|
|
334
|
+
title,
|
|
335
|
+
description,
|
|
336
|
+
targetBranch: finalTargetBranch,
|
|
337
|
+
sourceBranch,
|
|
338
|
+
authorization,
|
|
339
|
+
apiBaseUrl
|
|
340
|
+
});
|
|
341
|
+
ctx.output("pullRequestUrl", pullRequestUrl);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
exports.createPublishBitbucketCloudPullRequestAction = createPublishBitbucketCloudPullRequestAction;
|
|
347
|
+
//# sourceMappingURL=bitbucketCloudPullRequest.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitbucketCloudPullRequest.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.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 */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n commitAndPushBranch,\n addFiles,\n createBranch as createGitBranch,\n cloneRepo,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport fetch, { RequestInit, Response } from 'node-fetch';\nimport { Config } from '@backstage/config';\nimport fs from 'fs-extra';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloudPullRequest.examples';\n\nconst createPullRequest = async (opts: {\n workspace: string;\n repo: string;\n title: string;\n description?: string;\n targetBranch: string;\n sourceBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n repo,\n title,\n description,\n targetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n let response: Response;\n const data: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n title: title,\n summary: {\n raw: description,\n },\n state: 'OPEN',\n source: {\n branch: {\n name: sourceBranch,\n },\n },\n destination: {\n branch: {\n name: targetBranch,\n },\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/pullrequests`,\n data,\n );\n } catch (e) {\n throw new Error(`Unable to create pull-reqeusts, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create pull requests, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n return r.links.html.href;\n};\n\nconst findBranches = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const { workspace, repo, branchName, authorization, apiBaseUrl } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches?q=${encodeURIComponent(\n `name = \"${branchName}\"`,\n )}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to get branches, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to get branches, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n\n return r.values[0];\n};\nconst createBranch = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n startBranch: string;\n}) => {\n const {\n workspace,\n repo,\n branchName,\n authorization,\n apiBaseUrl,\n startBranch,\n } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: branchName,\n target: {\n hash: startBranch,\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create branch, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create branch, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n return await response.json();\n};\nconst getDefaultBranch = async (opts: {\n workspace: string;\n repo: string;\n authorization: string;\n apiBaseUrl: string;\n}): Promise<string> => {\n const { workspace, repo, authorization, apiBaseUrl } = opts;\n let response: Response;\n\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (error) {\n throw error;\n }\n\n const { mainbranch } = await response.json();\n const defaultBranch = mainbranch.name;\n if (!defaultBranch) {\n throw new Error(`Could not fetch default branch for ${workspace}/${repo}`);\n }\n return defaultBranch;\n};\n/**\n * Creates a Bitbucket Cloud Pull Request action.\n * @public\n */\nexport function createPublishBitbucketCloudPullRequestAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n title: string;\n description?: string;\n targetBranch?: string;\n sourceBranch: string;\n token?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:bitbucketCloud:pull-request',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'title', 'sourceBranch'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n title: {\n title: 'Pull Request title',\n type: 'string',\n description: 'The title for the pull request',\n },\n description: {\n title: 'Pull Request Description',\n type: 'string',\n description: 'The description of the pull request',\n },\n targetBranch: {\n title: 'Target Branch',\n type: 'string',\n description: `Branch of repository to apply changes to. The default value is 'master'`,\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n description: 'Branch of repository to copy changes from',\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description:\n 'The token to use for authorization to BitBucket Cloud',\n },\n gitAuthorName: {\n title: 'Author Name',\n type: 'string',\n description: `Sets the author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Author Email',\n type: 'string',\n description: `Sets the author email for the commit.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n pullRequestUrl: {\n title: 'A URL to the pull request with the provider',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n description,\n targetBranch,\n sourceBranch,\n gitAuthorName,\n gitAuthorEmail,\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 = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n let finalTargetBranch = targetBranch;\n if (!finalTargetBranch) {\n finalTargetBranch = await getDefaultBranch({\n workspace,\n repo,\n authorization,\n apiBaseUrl,\n });\n }\n\n const sourceBranchRef = await findBranches({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n if (!sourceBranchRef) {\n // create branch\n ctx.logger.info(\n `source branch not found -> creating branch named: ${sourceBranch}`,\n );\n\n await createBranch({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n startBranch: finalTargetBranch,\n });\n\n const remoteUrl = `https://${host}/${workspace}/${repo}.git`;\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 gitAuthorInfo = {\n name:\n gitAuthorName ||\n config.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ||\n config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const tempDir = await ctx.createTemporaryDirectory();\n const sourceDir = getRepoSourceDirectory(ctx.workspacePath, undefined);\n await cloneRepo({\n url: remoteUrl,\n dir: tempDir,\n auth,\n logger: ctx.logger,\n ref: sourceBranch,\n });\n\n await createGitBranch({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n ref: sourceBranch,\n });\n\n // copy files\n fs.cpSync(sourceDir, tempDir, {\n recursive: true,\n filter: path => {\n return !(path.indexOf('.git') > -1);\n },\n });\n\n await addFiles({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n filepath: '.',\n });\n\n await commitAndPushBranch({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n commitMessage:\n description ??\n config.getOptionalString('scaffolder.defaultCommitMessage') ??\n '',\n gitAuthorInfo,\n branch: sourceBranch,\n });\n }\n\n const pullRequestUrl = await createPullRequest({\n workspace,\n repo,\n title,\n description,\n targetBranch: finalTargetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n ctx.output('pullRequestUrl', pullRequestUrl);\n },\n });\n}\n"],"names":["fetch","createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","getRepoSourceDirectory","cloneRepo","createGitBranch","fs","addFiles","comm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