@salesforce/plugin-devops-center 1.2.28 → 1.4.0
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/README.md +184 -89
- package/bin/dev.js +0 -0
- package/bin/run.js +0 -0
- package/lib/commands/devops/pipeline/activate.js +5 -0
- package/lib/commands/devops/pipeline/activate.js.map +1 -1
- package/lib/commands/devops/pipeline/create.d.ts +2 -1
- package/lib/commands/devops/pipeline/create.js +37 -7
- package/lib/commands/devops/pipeline/create.js.map +1 -1
- package/lib/commands/devops/pipeline/{attach-project.d.ts → project/add.d.ts} +2 -2
- package/lib/commands/devops/pipeline/{attach-project.js → project/add.js} +5 -5
- package/lib/commands/devops/pipeline/project/add.js.map +1 -0
- package/lib/commands/devops/pull-request/create.d.ts +0 -2
- package/lib/commands/devops/pull-request/create.js +8 -40
- package/lib/commands/devops/pull-request/create.js.map +1 -1
- package/lib/commands/devops/stage/branch/add.d.ts +17 -0
- package/lib/commands/devops/stage/branch/add.js +110 -0
- package/lib/commands/devops/stage/branch/add.js.map +1 -0
- package/lib/commands/devops/stage/environment/add.d.ts +18 -0
- package/lib/commands/devops/stage/environment/add.js +141 -0
- package/lib/commands/devops/stage/environment/add.js.map +1 -0
- package/lib/commands/devops/work-item/{status/update.d.ts → update.d.ts} +6 -4
- package/lib/commands/devops/work-item/{status/update.js → update.js} +30 -9
- package/lib/commands/devops/work-item/update.js.map +1 -0
- package/lib/utils/addStageBranch.d.ts +22 -0
- package/lib/utils/addStageBranch.js +48 -0
- package/lib/utils/addStageBranch.js.map +1 -0
- package/lib/utils/addStageEnvironment.d.ts +92 -0
- package/lib/utils/addStageEnvironment.js +120 -0
- package/lib/utils/addStageEnvironment.js.map +1 -0
- package/lib/utils/createPipeline.d.ts +14 -1
- package/lib/utils/createPipeline.js +52 -6
- package/lib/utils/createPipeline.js.map +1 -1
- package/lib/utils/createProject.js +1 -0
- package/lib/utils/createProject.js.map +1 -1
- package/lib/utils/createPullRequest.d.ts +7 -19
- package/lib/utils/createPullRequest.js +49 -121
- package/lib/utils/createPullRequest.js.map +1 -1
- package/lib/utils/{updateWorkItemStatus.d.ts → updateWorkItem.d.ts} +12 -14
- package/lib/utils/{updateWorkItemStatus.js → updateWorkItem.js} +28 -26
- package/lib/utils/updateWorkItem.js.map +1 -0
- package/messages/devops.pipeline.create.md +26 -6
- package/messages/devops.pull-request.create.md +6 -30
- package/messages/devops.stage.branch.add.md +46 -0
- package/messages/devops.stage.environment.add.md +65 -0
- package/messages/devops.work-item.update.md +45 -0
- package/npm-shrinkwrap.json +2 -2
- package/oclif.manifest.json +470 -267
- package/package.json +3 -3
- package/schemas/devops-pull__request-create.json +0 -3
- package/schemas/devops-stage-branch-add.json +34 -0
- package/schemas/devops-stage-environment-add.json +47 -0
- package/schemas/{devops-work__item-status-update.json → devops-work__item-update.json} +8 -2
- package/lib/commands/devops/pipeline/attach-project.js.map +0 -1
- package/lib/commands/devops/work-item/status/update.js.map +0 -1
- package/lib/utils/updateWorkItemStatus.js.map +0 -1
- package/messages/devops.work-item.status.update.md +0 -29
- /package/messages/{devops.pipeline.attach-project.md → devops.pipeline.project.add.md} +0 -0
- /package/schemas/{devops-pipeline-attach__project.json → devops-pipeline-project-add.json} +0 -0
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Messages } from '@salesforce/core';
|
|
17
17
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { attachProject, findExistingAttachment } from '
|
|
18
|
+
import { attachProject, findExistingAttachment } from '../../../../utils/attachProject.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
|
-
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.pipeline.
|
|
20
|
+
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.pipeline.project.add');
|
|
21
21
|
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
22
|
-
export default class
|
|
22
|
+
export default class DevopsPipelineProjectAdd extends SfCommand {
|
|
23
23
|
static summary = messages.getMessage('summary');
|
|
24
24
|
static description = messages.getMessage('description');
|
|
25
25
|
static examples = messages.getMessages('examples');
|
|
@@ -38,7 +38,7 @@ export default class DevopsPipelineAttachProject extends SfCommand {
|
|
|
38
38
|
}),
|
|
39
39
|
};
|
|
40
40
|
async run() {
|
|
41
|
-
const { flags } = await this.parse(
|
|
41
|
+
const { flags } = await this.parse(DevopsPipelineProjectAdd);
|
|
42
42
|
const org = flags['target-org'];
|
|
43
43
|
const connection = org.getConnection(flags['api-version']);
|
|
44
44
|
const projectId = flags['project-id'];
|
|
@@ -79,4 +79,4 @@ export default class DevopsPipelineAttachProject extends SfCommand {
|
|
|
79
79
|
return result;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../../src/commands/devops/pipeline/project/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAuB,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEhH,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,6BAA6B,CAAC,CAAC;AAC1G,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAEtG,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAA8B;IAC3E,MAAM,CAAU,OAAO,GA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M,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,yCAAyC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -10,8 +10,6 @@ export default class DevopsPullRequestCreate extends SfCommand<CreatePullRequest
|
|
|
10
10
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'work-item-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
'work-item-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
-
body: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
13
|
};
|
|
16
14
|
run(): Promise<CreatePullRequestResult>;
|
|
17
15
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Messages } from '@salesforce/core';
|
|
17
17
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { createPullRequest, fetchWorkItemDetail,
|
|
18
|
+
import { createPullRequest, fetchWorkItemDetail, } from '../../../utils/createPullRequest.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
20
|
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.pull-request.create');
|
|
21
21
|
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
@@ -36,12 +36,6 @@ export default class DevopsPullRequestCreate extends SfCommand {
|
|
|
36
36
|
char: 'w',
|
|
37
37
|
exactlyOne: ['work-item-name', 'work-item-id'],
|
|
38
38
|
}),
|
|
39
|
-
title: Flags.string({
|
|
40
|
-
summary: messages.getMessage('flags.title.summary'),
|
|
41
|
-
}),
|
|
42
|
-
body: Flags.string({
|
|
43
|
-
summary: messages.getMessage('flags.body.summary'),
|
|
44
|
-
}),
|
|
45
39
|
};
|
|
46
40
|
async run() {
|
|
47
41
|
const { flags } = await this.parse(DevopsPullRequestCreate);
|
|
@@ -62,41 +56,15 @@ export default class DevopsPullRequestCreate extends SfCommand {
|
|
|
62
56
|
if (!detail.branchName) {
|
|
63
57
|
this.error(messages.getMessage('error.NoBranch', [detail.workItemName]));
|
|
64
58
|
}
|
|
65
|
-
|
|
66
|
-
this.error(messages.getMessage('error.NoRepo', [detail.workItemName]));
|
|
67
|
-
}
|
|
68
|
-
if (!detail.targetBranch) {
|
|
69
|
-
this.error(messages.getMessage('error.NoTargetBranch', [detail.workItemName]));
|
|
70
|
-
}
|
|
71
|
-
if (!detail.provider) {
|
|
72
|
-
this.error(messages.getMessage('error.NoProvider', [detail.workItemName]));
|
|
73
|
-
}
|
|
74
|
-
let token;
|
|
75
|
-
if (detail.provider === 'github') {
|
|
76
|
-
token = await resolveGitHubToken();
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
token = process.env.BITBUCKET_TOKEN;
|
|
80
|
-
}
|
|
81
|
-
if (!token) {
|
|
82
|
-
this.error(messages.getMessage('error.NoToken', [detail.provider]));
|
|
83
|
-
}
|
|
84
|
-
const prTitle = flags['title'] ?? detail.subject;
|
|
85
|
-
const result = await createPullRequest({
|
|
86
|
-
owner: detail.repoOwner,
|
|
87
|
-
repo: detail.repoName,
|
|
88
|
-
head: detail.branchName,
|
|
89
|
-
base: detail.targetBranch,
|
|
90
|
-
title: prTitle,
|
|
91
|
-
body: flags['body'],
|
|
92
|
-
provider: detail.provider,
|
|
93
|
-
token,
|
|
94
|
-
});
|
|
59
|
+
const result = await createPullRequest(connection, detail.workItemId);
|
|
95
60
|
if (result.success) {
|
|
96
61
|
this.log(`Successfully created pull request for ${detail.workItemName}.`);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
62
|
+
if (result.url) {
|
|
63
|
+
this.log(` URL: ${result.url}`);
|
|
64
|
+
}
|
|
65
|
+
if (detail.branchName && detail.targetBranch) {
|
|
66
|
+
this.log(` Source: ${detail.branchName} → ${detail.targetBranch}`);
|
|
67
|
+
}
|
|
100
68
|
}
|
|
101
69
|
return result;
|
|
102
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/devops/pull-request/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/devops/pull-request/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,GAEpB,MAAM,qCAAqC,CAAC;AAE7C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,4BAA4B,CAAC,CAAC;AACzG,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAEtG,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,SAAkC;IAC9E,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,C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AAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBAC3E,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QAEtE,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,yCAAyC,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;YAC1E,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YACnC,CAAC;YACD,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;gBAC7C,IAAI,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,UAAU,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Org } from '@salesforce/core';
|
|
2
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { AddStageBranchResult } from '../../../../utils/addStageBranch.js';
|
|
4
|
+
export default class DevopsStageBranchAdd extends SfCommand<AddStageBranchResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'pipeline-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'stage-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'branch-name': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'create-vcs-branch': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<AddStageBranchResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { addStageBranch } from '../../../../utils/addStageBranch.js';
|
|
19
|
+
import { fetchPipelineStages } from '../../../../utils/pipelineUtils.js';
|
|
20
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
|
+
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.stage.branch.add');
|
|
22
|
+
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
23
|
+
export default class DevopsStageBranchAdd extends SfCommand {
|
|
24
|
+
static summary = messages.getMessage('summary');
|
|
25
|
+
static description = messages.getMessage('description');
|
|
26
|
+
static examples = messages.getMessages('examples');
|
|
27
|
+
static flags = {
|
|
28
|
+
'target-org': Flags.requiredOrg(),
|
|
29
|
+
'api-version': Flags.orgApiVersion(),
|
|
30
|
+
'pipeline-id': Flags.salesforceId({
|
|
31
|
+
summary: messages.getMessage('flags.pipeline-id.summary'),
|
|
32
|
+
required: true,
|
|
33
|
+
char: undefined,
|
|
34
|
+
}),
|
|
35
|
+
'stage-id': Flags.salesforceId({
|
|
36
|
+
summary: messages.getMessage('flags.stage-id.summary'),
|
|
37
|
+
required: true,
|
|
38
|
+
char: undefined,
|
|
39
|
+
}),
|
|
40
|
+
'branch-name': Flags.string({
|
|
41
|
+
summary: messages.getMessage('flags.branch-name.summary'),
|
|
42
|
+
required: true,
|
|
43
|
+
char: 'b',
|
|
44
|
+
}),
|
|
45
|
+
'create-vcs-branch': Flags.boolean({
|
|
46
|
+
summary: messages.getMessage('flags.create-vcs-branch.summary'),
|
|
47
|
+
default: false,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
async run() {
|
|
51
|
+
const { flags } = await this.parse(DevopsStageBranchAdd);
|
|
52
|
+
const org = flags['target-org'];
|
|
53
|
+
const connection = org.getConnection(flags['api-version']);
|
|
54
|
+
const pipelineId = flags['pipeline-id'];
|
|
55
|
+
const stageId = flags['stage-id'];
|
|
56
|
+
let stages;
|
|
57
|
+
try {
|
|
58
|
+
stages = await fetchPipelineStages(connection, pipelineId);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
62
|
+
if (errMsg.includes('sObject type') && errMsg.includes('is not supported')) {
|
|
63
|
+
this.error(commonErrorMessages.getMessage('error.DevopsCenterNotEnabled'));
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
const targetStage = stages.find((s) => s.Id === stageId);
|
|
68
|
+
if (!targetStage) {
|
|
69
|
+
this.error(messages.getMessage('error.StageNotFound', [stageId, pipelineId]));
|
|
70
|
+
}
|
|
71
|
+
// Enforce right-to-left branch setup order: the next stage (to the right)
|
|
72
|
+
// must already have a branch before this stage can be configured.
|
|
73
|
+
if (targetStage.NextStageId) {
|
|
74
|
+
const nextStage = stages.find((s) => s.Id === targetStage.NextStageId);
|
|
75
|
+
if (nextStage && !nextStage.SourceCodeRepositoryBranch?.Name) {
|
|
76
|
+
this.error(messages.getMessage('error.NextStageNoBranch', [nextStage.Name ?? nextStage.Id, stageId]));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
let result;
|
|
80
|
+
try {
|
|
81
|
+
result = await addStageBranch({
|
|
82
|
+
connection,
|
|
83
|
+
pipelineId,
|
|
84
|
+
stageId,
|
|
85
|
+
branchName: flags['branch-name'],
|
|
86
|
+
createVcsBranch: flags['create-vcs-branch'],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
91
|
+
if (errMsg.includes('sObject type') && errMsg.includes('is not supported')) {
|
|
92
|
+
this.error(commonErrorMessages.getMessage('error.DevopsCenterNotEnabled'));
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
if (result.success) {
|
|
97
|
+
const action = result.branchCreated ? 'Created branch and associated it' : 'Successfully associated branch';
|
|
98
|
+
this.log(`${action} with the stage.`);
|
|
99
|
+
this.log(` Stage ID: ${stageId}`);
|
|
100
|
+
this.log(` Branch: ${result.branchName ?? ''}${result.branchCreated ? ' (newly created)' : ''}`);
|
|
101
|
+
this.log(` Repo Branch ID: ${result.repoBranchId ?? ''}`);
|
|
102
|
+
this.log(` Pipeline ID: ${pipelineId}`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.error(messages.getMessage('error.BranchAttachFailed', [result.error ?? '']));
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../../src/commands/devops/stage/branch/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAwB,MAAM,qCAAqC,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,yBAAyB,CAAC,CAAC;AACtG,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAEtG,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,SAA+B;IACxE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAA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IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Org } from '@salesforce/core';
|
|
2
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { AddStageEnvironmentResult } from '../../../../utils/addStageEnvironment.js';
|
|
4
|
+
export default class DevopsStageEnvironmentAdd extends SfCommand<AddStageEnvironmentResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'pipeline-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'stage-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'environment-name': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'org-type': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'no-browser': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<AddStageEnvironmentResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { exec } from 'node:child_process';
|
|
17
|
+
import { Messages } from '@salesforce/core';
|
|
18
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
19
|
+
import { addStageEnvironment } from '../../../../utils/addStageEnvironment.js';
|
|
20
|
+
import { fetchPipelineStages } from '../../../../utils/pipelineUtils.js';
|
|
21
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
22
|
+
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.stage.environment.add');
|
|
23
|
+
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
24
|
+
function openUrl(url) {
|
|
25
|
+
const platform = process.platform;
|
|
26
|
+
const cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';
|
|
27
|
+
exec(`${cmd} "${url}"`);
|
|
28
|
+
}
|
|
29
|
+
function decodeRedirectUrl(url) {
|
|
30
|
+
return url.replace(/&/g, '&');
|
|
31
|
+
}
|
|
32
|
+
export default class DevopsStageEnvironmentAdd extends SfCommand {
|
|
33
|
+
static summary = messages.getMessage('summary');
|
|
34
|
+
static description = messages.getMessage('description');
|
|
35
|
+
static examples = messages.getMessages('examples');
|
|
36
|
+
static flags = {
|
|
37
|
+
'target-org': Flags.requiredOrg(),
|
|
38
|
+
'api-version': Flags.orgApiVersion(),
|
|
39
|
+
'pipeline-id': Flags.salesforceId({
|
|
40
|
+
summary: messages.getMessage('flags.pipeline-id.summary'),
|
|
41
|
+
required: true,
|
|
42
|
+
char: undefined,
|
|
43
|
+
}),
|
|
44
|
+
'stage-id': Flags.salesforceId({
|
|
45
|
+
summary: messages.getMessage('flags.stage-id.summary'),
|
|
46
|
+
required: true,
|
|
47
|
+
char: undefined,
|
|
48
|
+
}),
|
|
49
|
+
'environment-name': Flags.string({
|
|
50
|
+
summary: messages.getMessage('flags.environment-name.summary'),
|
|
51
|
+
required: true,
|
|
52
|
+
char: 'e',
|
|
53
|
+
}),
|
|
54
|
+
'org-type': Flags.string({
|
|
55
|
+
summary: messages.getMessage('flags.org-type.summary'),
|
|
56
|
+
required: true,
|
|
57
|
+
options: ['Production', 'Sandbox'],
|
|
58
|
+
}),
|
|
59
|
+
'no-browser': Flags.boolean({
|
|
60
|
+
summary: messages.getMessage('flags.no-browser.summary'),
|
|
61
|
+
default: false,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
async run() {
|
|
65
|
+
const { flags } = await this.parse(DevopsStageEnvironmentAdd);
|
|
66
|
+
const org = flags['target-org'];
|
|
67
|
+
const connection = org.getConnection(flags['api-version']);
|
|
68
|
+
const pipelineId = flags['pipeline-id'];
|
|
69
|
+
const stageId = flags['stage-id'];
|
|
70
|
+
const environmentName = flags['environment-name'];
|
|
71
|
+
const orgType = flags['org-type'];
|
|
72
|
+
const noBrowser = flags['no-browser'];
|
|
73
|
+
let stages;
|
|
74
|
+
try {
|
|
75
|
+
stages = await fetchPipelineStages(connection, pipelineId);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
79
|
+
if (errMsg.includes('sObject type') && errMsg.includes('is not supported')) {
|
|
80
|
+
this.error(commonErrorMessages.getMessage('error.DevopsCenterNotEnabled'));
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
if (!stages.some((s) => s.Id === stageId)) {
|
|
85
|
+
this.error(messages.getMessage('error.StageNotFound', [stageId, pipelineId]));
|
|
86
|
+
}
|
|
87
|
+
const pipelineQueryResult = await connection.query(`SELECT IsActive FROM DevopsPipeline WHERE Id = '${pipelineId}' LIMIT 1`);
|
|
88
|
+
const pipelineRecord = (pipelineQueryResult.records ?? [])[0];
|
|
89
|
+
if (pipelineRecord?.IsActive) {
|
|
90
|
+
this.error(messages.getMessage('error.PipelineAlreadyActive', [pipelineId]));
|
|
91
|
+
}
|
|
92
|
+
let result;
|
|
93
|
+
try {
|
|
94
|
+
result = await addStageEnvironment({
|
|
95
|
+
connection,
|
|
96
|
+
pipelineId,
|
|
97
|
+
stageId,
|
|
98
|
+
environmentName,
|
|
99
|
+
orgType,
|
|
100
|
+
onCreated: (data) => {
|
|
101
|
+
const url = decodeRedirectUrl(data.redirectUrl);
|
|
102
|
+
if (!noBrowser) {
|
|
103
|
+
openUrl(url);
|
|
104
|
+
this.log(messages.getMessage('info.BrowserOpened'));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.log(messages.getMessage('info.ManualAuth', [url]));
|
|
108
|
+
}
|
|
109
|
+
this.spinner.start(messages.getMessage('info.WaitingForAuth'));
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
115
|
+
if (errMsg.includes('sObject type') && errMsg.includes('is not supported')) {
|
|
116
|
+
this.error(commonErrorMessages.getMessage('error.DevopsCenterNotEnabled'));
|
|
117
|
+
}
|
|
118
|
+
if (errMsg.includes('timed out')) {
|
|
119
|
+
this.error(messages.getMessage('error.AuthTimeout'));
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
this.spinner.stop();
|
|
125
|
+
}
|
|
126
|
+
if (result.success) {
|
|
127
|
+
this.log(messages.getMessage('info.Success'));
|
|
128
|
+
this.log(` Stage ID: ${stageId}`);
|
|
129
|
+
this.log(` Environment ID: ${result.environmentId ?? ''}`);
|
|
130
|
+
this.log(` Environment Name: ${result.environmentName ?? ''}`);
|
|
131
|
+
this.log(` Org Type: ${orgType}`);
|
|
132
|
+
this.log(` Pipeline ID: ${pipelineId}`);
|
|
133
|
+
this.log(` Organization ID: ${result.organizationId ?? ''}`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.error(messages.getMessage('error.EnvironmentAttachFailed', [result.error ?? '']));
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../../src/commands/devops/stage/environment/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAsC,MAAM,0CAA0C,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,8BAA8B,CAAC,CAAC;AAC3G,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAEtG,SAAS,OAAO,CAAC,GAAW;IAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,GAAG,GAAG,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACzF,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;AA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+BAA+B,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Org } from '@salesforce/core';
|
|
2
2
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
-
import {
|
|
4
|
-
export default class
|
|
3
|
+
import { UpdateWorkItemResult } from '../../../utils/updateWorkItem.js';
|
|
4
|
+
export default class DevopsWorkItemUpdate extends SfCommand<UpdateWorkItemResult> {
|
|
5
5
|
static readonly summary: string;
|
|
6
6
|
static readonly description: string;
|
|
7
7
|
static readonly examples: string[];
|
|
@@ -10,7 +10,9 @@ export default class DevopsWorkItemStatusUpdate extends SfCommand<UpdateWorkItem
|
|
|
10
10
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'work-item-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
'work-item-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
-
|
|
13
|
+
subject: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
};
|
|
15
|
-
run(): Promise<
|
|
17
|
+
run(): Promise<UpdateWorkItemResult>;
|
|
16
18
|
}
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Messages } from '@salesforce/core';
|
|
17
17
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { resolveWorkItemByName, resolveProjectIdForWorkItem,
|
|
18
|
+
import { resolveWorkItemByName, resolveProjectIdForWorkItem, updateWorkItem, ALLOWED_STATUSES, } from '../../../utils/updateWorkItem.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
|
-
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.work-item.
|
|
20
|
+
const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'devops.work-item.update');
|
|
21
21
|
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
22
|
-
export default class
|
|
22
|
+
export default class DevopsWorkItemUpdate extends SfCommand {
|
|
23
23
|
static summary = messages.getMessage('summary');
|
|
24
24
|
static description = messages.getMessage('description');
|
|
25
25
|
static examples = messages.getMessages('examples');
|
|
@@ -36,14 +36,22 @@ export default class DevopsWorkItemStatusUpdate extends SfCommand {
|
|
|
36
36
|
char: 'w',
|
|
37
37
|
exactlyOne: ['work-item-name', 'work-item-id'],
|
|
38
38
|
}),
|
|
39
|
+
subject: Flags.string({
|
|
40
|
+
summary: messages.getMessage('flags.subject.summary'),
|
|
41
|
+
}),
|
|
42
|
+
description: Flags.string({
|
|
43
|
+
summary: messages.getMessage('flags.description.summary'),
|
|
44
|
+
}),
|
|
39
45
|
status: Flags.string({
|
|
40
46
|
summary: messages.getMessage('flags.status.summary'),
|
|
41
|
-
required: true,
|
|
42
47
|
options: [...ALLOWED_STATUSES],
|
|
43
48
|
}),
|
|
44
49
|
};
|
|
45
50
|
async run() {
|
|
46
|
-
const { flags } = await this.parse(
|
|
51
|
+
const { flags } = await this.parse(DevopsWorkItemUpdate);
|
|
52
|
+
if (!flags['subject'] && !flags['description'] && !flags['status']) {
|
|
53
|
+
this.error(messages.getMessage('error.NoFieldsProvided'));
|
|
54
|
+
}
|
|
47
55
|
const org = flags['target-org'];
|
|
48
56
|
const connection = org.getConnection(flags['api-version']);
|
|
49
57
|
let workItemId;
|
|
@@ -68,7 +76,14 @@ export default class DevopsWorkItemStatusUpdate extends SfCommand {
|
|
|
68
76
|
}
|
|
69
77
|
let result;
|
|
70
78
|
try {
|
|
71
|
-
result = await
|
|
79
|
+
result = await updateWorkItem({
|
|
80
|
+
connection,
|
|
81
|
+
workItemId,
|
|
82
|
+
projectId,
|
|
83
|
+
status: flags['status'],
|
|
84
|
+
subject: flags['subject'],
|
|
85
|
+
description: flags['description'],
|
|
86
|
+
});
|
|
72
87
|
}
|
|
73
88
|
catch (error) {
|
|
74
89
|
const errMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -78,11 +93,17 @@ export default class DevopsWorkItemStatusUpdate extends SfCommand {
|
|
|
78
93
|
throw error;
|
|
79
94
|
}
|
|
80
95
|
if (result.success) {
|
|
81
|
-
const identifier = flags['work-item-name'] ??
|
|
82
|
-
this.log(`Successfully updated
|
|
96
|
+
const identifier = flags['work-item-name'] ?? workItemId;
|
|
97
|
+
this.log(`Successfully updated work item ${identifier}.`);
|
|
98
|
+
if (result.subject !== undefined)
|
|
99
|
+
this.log(` Subject: ${result.subject}`);
|
|
100
|
+
if (result.description !== undefined)
|
|
101
|
+
this.log(` Description: ${result.description}`);
|
|
102
|
+
if (result.status !== undefined)
|
|
103
|
+
this.log(` Status: ${result.status}`);
|
|
83
104
|
}
|
|
84
105
|
else {
|
|
85
|
-
this.error(`Failed to update work item
|
|
106
|
+
this.error(`Failed to update work item: ${result.error ?? ''}`);
|
|
86
107
|
}
|
|
87
108
|
return result;
|
|
88
109
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/devops/work-item/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EAEd,g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C,kBAAkB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/E,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;gBAAE,IAAI,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;YACvF,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;gBAAE,IAAI,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,+BAA+B,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type AddStageBranchParams = {
|
|
3
|
+
connection: Connection;
|
|
4
|
+
pipelineId: string;
|
|
5
|
+
stageId: string;
|
|
6
|
+
branchName: string;
|
|
7
|
+
createVcsBranch: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type AddStageBranchResult = {
|
|
10
|
+
success: boolean;
|
|
11
|
+
stageId: string;
|
|
12
|
+
branchName?: string;
|
|
13
|
+
branchCreated?: boolean;
|
|
14
|
+
repoBranchId?: string;
|
|
15
|
+
pipelineId?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Associates a branch with a pipeline stage via the Connect API.
|
|
20
|
+
* PATCH /services/data/v{version}/connect/devops/pipelines/{pipelineId}/stages/{stageId}
|
|
21
|
+
*/
|
|
22
|
+
export declare function addStageBranch(params: AddStageBranchParams): Promise<AddStageBranchResult>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Associates a branch with a pipeline stage via the Connect API.
|
|
18
|
+
* PATCH /services/data/v{version}/connect/devops/pipelines/{pipelineId}/stages/{stageId}
|
|
19
|
+
*/
|
|
20
|
+
export async function addStageBranch(params) {
|
|
21
|
+
const { connection, pipelineId, stageId, branchName, createVcsBranch } = params;
|
|
22
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/pipelines/${pipelineId}/stages/${stageId}`;
|
|
23
|
+
const data = await connection.request({
|
|
24
|
+
method: 'PATCH',
|
|
25
|
+
url: path,
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
vcsBranch: branchName,
|
|
28
|
+
createVcsBranch: String(createVcsBranch),
|
|
29
|
+
}),
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
});
|
|
32
|
+
if (data.status === 'FAILED') {
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
stageId,
|
|
36
|
+
error: data.message ?? 'Failed to associate branch with stage',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
stageId,
|
|
42
|
+
branchName,
|
|
43
|
+
branchCreated: createVcsBranch,
|
|
44
|
+
repoBranchId: data.repoBranchId,
|
|
45
|
+
pipelineId,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=addStageBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addStageBranch.js","sourceRoot":"","sources":["../../src/utils/addStageBranch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6BH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAA4B;IAC/D,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAEhF,MAAM,IAAI,GAAG,mBAAmB,UAAU,CAAC,aAAa,EAAE,6BAA6B,UAAU,WAAW,OAAO,EAAE,CAAC;IAEtH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAA6B;QAChE,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,SAAS,EAAE,UAAU;YACrB,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC;SACzC,CAAC;QACF,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO;YACP,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,uCAAuC;SAC/D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO;QACP,UAAU;QACV,aAAa,EAAE,eAAe;QAC9B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC"}
|