@salesforce/plugin-devops-center 1.2.28 → 1.3.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 +100 -15
- package/bin/dev.js +0 -0
- package/bin/run.js +0 -0
- package/lib/commands/devops/stage/add-branch.d.ts +17 -0
- package/lib/commands/devops/stage/add-branch.js +110 -0
- package/lib/commands/devops/stage/add-branch.js.map +1 -0
- package/lib/commands/devops/stage/add-environment.d.ts +18 -0
- package/lib/commands/devops/stage/add-environment.js +136 -0
- package/lib/commands/devops/stage/add-environment.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/messages/devops.stage.add-branch.md +46 -0
- package/messages/devops.stage.add-environment.md +61 -0
- package/npm-shrinkwrap.json +2 -2
- package/oclif.manifest.json +369 -176
- package/package.json +3 -3
- package/schemas/devops-stage-add__branch.json +34 -0
- package/schemas/devops-stage-add__environment.json +47 -0
package/README.md
CHANGED
|
@@ -63,6 +63,8 @@ sf plugins
|
|
|
63
63
|
- [`sf devops project create`](#sf-devops-project-create)
|
|
64
64
|
- [`sf devops project list`](#sf-devops-project-list)
|
|
65
65
|
- [`sf devops pull-request create`](#sf-devops-pull-request-create)
|
|
66
|
+
- [`sf devops stage add-branch`](#sf-devops-stage-add-branch)
|
|
67
|
+
- [`sf devops stage add-environment`](#sf-devops-stage-add-environment)
|
|
66
68
|
- [`sf devops work-item create`](#sf-devops-work-item-create)
|
|
67
69
|
- [`sf devops work-item list`](#sf-devops-work-item-list)
|
|
68
70
|
- [`sf devops work-item status update`](#sf-devops-work-item-status-update)
|
|
@@ -102,7 +104,7 @@ EXAMPLES
|
|
|
102
104
|
$ sf devops pipeline activate --target-org my-devops-org --pipeline-id 0XB000000000001
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
_See code: [src/commands/devops/pipeline/activate.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
107
|
+
_See code: [src/commands/devops/pipeline/activate.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/pipeline/activate.ts)_
|
|
106
108
|
|
|
107
109
|
## `sf devops pipeline attach-project`
|
|
108
110
|
|
|
@@ -136,7 +138,7 @@ EXAMPLES
|
|
|
136
138
|
0Hn000000000001
|
|
137
139
|
```
|
|
138
140
|
|
|
139
|
-
_See code: [src/commands/devops/pipeline/attach-project.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
141
|
+
_See code: [src/commands/devops/pipeline/attach-project.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/pipeline/attach-project.ts)_
|
|
140
142
|
|
|
141
143
|
## `sf devops pipeline create`
|
|
142
144
|
|
|
@@ -190,7 +192,7 @@ EXAMPLES
|
|
|
190
192
|
https://bitbucket.org/myorg/myrepo --description "Main CI/CD pipeline for production releases"
|
|
191
193
|
```
|
|
192
194
|
|
|
193
|
-
_See code: [src/commands/devops/pipeline/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
195
|
+
_See code: [src/commands/devops/pipeline/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/pipeline/create.ts)_
|
|
194
196
|
|
|
195
197
|
## `sf devops pipeline stage add`
|
|
196
198
|
|
|
@@ -231,7 +233,7 @@ EXAMPLES
|
|
|
231
233
|
--next-stage-id 0Xc000000000003
|
|
232
234
|
```
|
|
233
235
|
|
|
234
|
-
_See code: [src/commands/devops/pipeline/stage/add.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
236
|
+
_See code: [src/commands/devops/pipeline/stage/add.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/pipeline/stage/add.ts)_
|
|
235
237
|
|
|
236
238
|
## `sf devops project create`
|
|
237
239
|
|
|
@@ -268,7 +270,7 @@ EXAMPLES
|
|
|
268
270
|
update"
|
|
269
271
|
```
|
|
270
272
|
|
|
271
|
-
_See code: [src/commands/devops/project/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
273
|
+
_See code: [src/commands/devops/project/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/project/create.ts)_
|
|
272
274
|
|
|
273
275
|
## `sf devops project list`
|
|
274
276
|
|
|
@@ -303,7 +305,7 @@ EXAMPLES
|
|
|
303
305
|
$ sf devops project list --target-org devops-center@example.com
|
|
304
306
|
```
|
|
305
307
|
|
|
306
|
-
_See code: [src/commands/devops/project/list.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
308
|
+
_See code: [src/commands/devops/project/list.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/project/list.ts)_
|
|
307
309
|
|
|
308
310
|
## `sf devops pull-request create`
|
|
309
311
|
|
|
@@ -345,7 +347,90 @@ EXAMPLES
|
|
|
345
347
|
timeout" --body "Resolves the 30s timeout on the login page"
|
|
346
348
|
```
|
|
347
349
|
|
|
348
|
-
_See code: [src/commands/devops/pull-request/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
350
|
+
_See code: [src/commands/devops/pull-request/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/pull-request/create.ts)_
|
|
351
|
+
|
|
352
|
+
## `sf devops stage add-branch`
|
|
353
|
+
|
|
354
|
+
Add a source code repository branch to a pipeline stage.
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
USAGE
|
|
358
|
+
$ sf devops stage add-branch -o <value> --pipeline-id <value> --stage-id <value> -b <value> [--json] [--flags-dir <value>]
|
|
359
|
+
[--api-version <value>] [--create-vcs-branch]
|
|
360
|
+
|
|
361
|
+
FLAGS
|
|
362
|
+
-b, --branch-name=<value> (required) Name of the repository branch to assign to the stage.
|
|
363
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
364
|
+
configuration variable is already set.
|
|
365
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
366
|
+
--create-vcs-branch Create the branch in the remote repository if it doesn't already exist.
|
|
367
|
+
--pipeline-id=<value> (required) ID of the pipeline that contains the stage.
|
|
368
|
+
--stage-id=<value> (required) ID of the pipeline stage to associate the branch with.
|
|
369
|
+
|
|
370
|
+
GLOBAL FLAGS
|
|
371
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
372
|
+
--json Format output as json.
|
|
373
|
+
|
|
374
|
+
DESCRIPTION
|
|
375
|
+
Add a source code repository branch to a pipeline stage.
|
|
376
|
+
|
|
377
|
+
By default, the branch must exist in the repository. Use --create-vcs-branch to create a branch if it doesn't exist.
|
|
378
|
+
Each pipeline stage supports only one branch. Adding a branch replaces any existing branch linked to the pipeline
|
|
379
|
+
stage.
|
|
380
|
+
|
|
381
|
+
EXAMPLES
|
|
382
|
+
Add an existing branch to a stage:
|
|
383
|
+
|
|
384
|
+
$ sf devops stage add-branch --target-org my-devops-org --pipeline-id 0Xo000000000001 --stage-id 0Xp000000000001 \
|
|
385
|
+
--branch-name main
|
|
386
|
+
|
|
387
|
+
Create and add a branch to a pipeline stage:
|
|
388
|
+
|
|
389
|
+
$ sf devops stage add-branch --target-org my-devops-org --pipeline-id 0Xo000000000001 --stage-id 0Xp000000000002 \
|
|
390
|
+
--branch-name integration --create-vcs-branch
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
_See code: [src/commands/devops/stage/add-branch.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/stage/add-branch.ts)_
|
|
394
|
+
|
|
395
|
+
## `sf devops stage add-environment`
|
|
396
|
+
|
|
397
|
+
Add a Salesforce environment to a pipeline stage.
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
USAGE
|
|
401
|
+
$ sf devops stage add-environment -o <value> --pipeline-id <value> --stage-id <value> -e <value> --org-type Production|Sandbox
|
|
402
|
+
[--json] [--flags-dir <value>] [--api-version <value>] [--no-browser]
|
|
403
|
+
|
|
404
|
+
FLAGS
|
|
405
|
+
-e, --environment-name=<value> (required) Name of the environment.
|
|
406
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
407
|
+
configuration variable is already set.
|
|
408
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
409
|
+
--no-browser Don't auto-open the browser for OAuth authentication. The redirect URL is printed for
|
|
410
|
+
manual use.
|
|
411
|
+
--org-type=<option> (required) Type of the Salesforce org. Valid values: Production, Sandbox.
|
|
412
|
+
<options: Production|Sandbox>
|
|
413
|
+
--pipeline-id=<value> (required) ID of the pipeline that contains the stage.
|
|
414
|
+
--stage-id=<value> (required) ID of the pipeline stage.
|
|
415
|
+
|
|
416
|
+
GLOBAL FLAGS
|
|
417
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
418
|
+
--json Format output as json.
|
|
419
|
+
|
|
420
|
+
DESCRIPTION
|
|
421
|
+
Add a Salesforce environment to a pipeline stage.
|
|
422
|
+
|
|
423
|
+
This command triggers an OAuth flow to authenticate the environment. A browser window opens automatically for you to
|
|
424
|
+
log in.
|
|
425
|
+
|
|
426
|
+
EXAMPLES
|
|
427
|
+
Add a production environment to a stage using its ID:
|
|
428
|
+
|
|
429
|
+
$ sf devops stage add-environment --target-org my-devops-org --stage-id 0Xp000000000001 --environment-name \
|
|
430
|
+
Production_Org --org-type Production
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
_See code: [src/commands/devops/stage/add-environment.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/stage/add-environment.ts)_
|
|
349
434
|
|
|
350
435
|
## `sf devops work-item create`
|
|
351
436
|
|
|
@@ -386,7 +471,7 @@ EXAMPLES
|
|
|
386
471
|
--description "Implement dark mode toggle in settings page"
|
|
387
472
|
```
|
|
388
473
|
|
|
389
|
-
_See code: [src/commands/devops/work-item/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
474
|
+
_See code: [src/commands/devops/work-item/create.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/work-item/create.ts)_
|
|
390
475
|
|
|
391
476
|
## `sf devops work-item list`
|
|
392
477
|
|
|
@@ -422,7 +507,7 @@ EXAMPLES
|
|
|
422
507
|
$ sf devops work-item list --target-org my-devops-org --project-id 1Qg000000000001 --json
|
|
423
508
|
```
|
|
424
509
|
|
|
425
|
-
_See code: [src/commands/devops/work-item/list.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
510
|
+
_See code: [src/commands/devops/work-item/list.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/work-item/list.ts)_
|
|
426
511
|
|
|
427
512
|
## `sf devops work-item status update`
|
|
428
513
|
|
|
@@ -463,7 +548,7 @@ EXAMPLES
|
|
|
463
548
|
Promote"
|
|
464
549
|
```
|
|
465
550
|
|
|
466
|
-
_See code: [src/commands/devops/work-item/status/update.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
551
|
+
_See code: [src/commands/devops/work-item/status/update.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/devops/work-item/status/update.ts)_
|
|
467
552
|
|
|
468
553
|
## `sf project deploy pipeline quick`
|
|
469
554
|
|
|
@@ -537,7 +622,7 @@ FLAG DESCRIPTIONS
|
|
|
537
622
|
"sf project deploy pipeline report".
|
|
538
623
|
```
|
|
539
624
|
|
|
540
|
-
_See code: [src/commands/project/deploy/pipeline/quick.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
625
|
+
_See code: [src/commands/project/deploy/pipeline/quick.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/project/deploy/pipeline/quick.ts)_
|
|
541
626
|
|
|
542
627
|
## `sf project deploy pipeline report`
|
|
543
628
|
|
|
@@ -585,7 +670,7 @@ FLAG DESCRIPTIONS
|
|
|
585
670
|
your most recent operation was longer than 3 days ago, this flag won't find the job ID.
|
|
586
671
|
```
|
|
587
672
|
|
|
588
|
-
_See code: [src/commands/project/deploy/pipeline/report.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
673
|
+
_See code: [src/commands/project/deploy/pipeline/report.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/project/deploy/pipeline/report.ts)_
|
|
589
674
|
|
|
590
675
|
## `sf project deploy pipeline resume`
|
|
591
676
|
|
|
@@ -652,7 +737,7 @@ FLAG DESCRIPTIONS
|
|
|
652
737
|
returns the job ID. To check the status of the operation, run "sf project deploy pipeline report".
|
|
653
738
|
```
|
|
654
739
|
|
|
655
|
-
_See code: [src/commands/project/deploy/pipeline/resume.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
740
|
+
_See code: [src/commands/project/deploy/pipeline/resume.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/project/deploy/pipeline/resume.ts)_
|
|
656
741
|
|
|
657
742
|
## `sf project deploy pipeline start`
|
|
658
743
|
|
|
@@ -752,7 +837,7 @@ FLAG DESCRIPTIONS
|
|
|
752
837
|
"sf project deploy pipeline report".
|
|
753
838
|
```
|
|
754
839
|
|
|
755
|
-
_See code: [src/commands/project/deploy/pipeline/start.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
840
|
+
_See code: [src/commands/project/deploy/pipeline/start.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/project/deploy/pipeline/start.ts)_
|
|
756
841
|
|
|
757
842
|
## `sf project deploy pipeline validate`
|
|
758
843
|
|
|
@@ -852,7 +937,7 @@ FLAG DESCRIPTIONS
|
|
|
852
937
|
"sf project deploy pipeline report".
|
|
853
938
|
```
|
|
854
939
|
|
|
855
|
-
_See code: [src/commands/project/deploy/pipeline/validate.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.
|
|
940
|
+
_See code: [src/commands/project/deploy/pipeline/validate.ts](https://github.com/salesforcecli/plugin-devops-center/blob/1.3.0/src/commands/project/deploy/pipeline/validate.ts)_
|
|
856
941
|
|
|
857
942
|
<!-- commandsstop -->
|
|
858
943
|
|
package/bin/dev.js
CHANGED
|
File without changes
|
package/bin/run.js
CHANGED
|
File without changes
|
|
@@ -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 DevopsStageAddBranch 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.add-branch');
|
|
22
|
+
const commonErrorMessages = Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
|
|
23
|
+
export default class DevopsStageAddBranch 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(DevopsStageAddBranch);
|
|
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-branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-branch.js","sourceRoot":"","sources":["../../../../src/commands/devops/stage/add-branch.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,kCAAkC,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,yBAAyB,CA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AAE,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1G,IAAI,CAAC,GAAG,CAAC,qBAAqB,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC,CAAC;YAC3D,IAAI,CAAC,GAAG,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC,MAAM,CAAC,KAAK,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 DevopsStageAddEnvironment 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,136 @@
|
|
|
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.add-environment');
|
|
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 DevopsStageAddEnvironment 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(DevopsStageAddEnvironment);
|
|
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
|
+
let result;
|
|
88
|
+
try {
|
|
89
|
+
result = await addStageEnvironment({
|
|
90
|
+
connection,
|
|
91
|
+
pipelineId,
|
|
92
|
+
stageId,
|
|
93
|
+
environmentName,
|
|
94
|
+
orgType,
|
|
95
|
+
onCreated: (data) => {
|
|
96
|
+
const url = decodeRedirectUrl(data.redirectUrl);
|
|
97
|
+
if (!noBrowser) {
|
|
98
|
+
openUrl(url);
|
|
99
|
+
this.log(messages.getMessage('info.BrowserOpened'));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.log(messages.getMessage('info.ManualAuth', [url]));
|
|
103
|
+
}
|
|
104
|
+
this.spinner.start(messages.getMessage('info.WaitingForAuth'));
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
110
|
+
if (errMsg.includes('sObject type') && errMsg.includes('is not supported')) {
|
|
111
|
+
this.error(commonErrorMessages.getMessage('error.DevopsCenterNotEnabled'));
|
|
112
|
+
}
|
|
113
|
+
if (errMsg.includes('timed out')) {
|
|
114
|
+
this.error(messages.getMessage('error.AuthTimeout'));
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
this.spinner.stop();
|
|
120
|
+
}
|
|
121
|
+
if (result.success) {
|
|
122
|
+
this.log(messages.getMessage('info.Success'));
|
|
123
|
+
this.log(` Stage ID: ${stageId}`);
|
|
124
|
+
this.log(` Environment ID: ${result.environmentId ?? ''}`);
|
|
125
|
+
this.log(` Environment Name: ${result.environmentName ?? ''}`);
|
|
126
|
+
this.log(` Org Type: ${orgType}`);
|
|
127
|
+
this.log(` Pipeline ID: ${pipelineId}`);
|
|
128
|
+
this.log(` Organization ID: ${result.organizationId ?? ''}`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.error(messages.getMessage('error.EnvironmentAttachFailed', [result.error ?? '']));
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=add-environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-environment.js","sourceRoot":"","sources":["../../../../src/commands/devops/stage/add-environment.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,uCAAuC,CAAC;AAChH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,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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
+
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"}
|