Skip to content

Commit 217004a

Browse files
authored
fix: quick deploy polling uses the new deploy ID (#815)
1 parent d481ac1 commit 217004a

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/commands/project/deploy/quick.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
9191
const deployOpts = cache.get(jobId) ?? ({} as DeployOptions);
9292
const org = flags['target-org'] ?? (await Org.create({ aliasOrUsername: deployOpts['target-org'] }));
9393
const api = await resolveApi(this.configAggregator);
94+
const connection = org.getConnection(flags['api-version']);
9495

95-
const mdapiDeploy = new MetadataApiDeploy({
96-
usernameOrConnection: org.getConnection(flags['api-version']),
96+
// This is the ID of the deploy (of the validated metadata)
97+
const deployId = await connection.metadata.deployRecentValidation({
9798
id: jobId,
98-
apiOptions: {
99-
rest: api === API['REST'],
100-
},
99+
rest: api === API['REST'],
101100
});
102-
// This is the ID of the deploy (of the validated metadata)
103-
const deployId = await mdapiDeploy.deployRecentValidation(api === API['REST']);
104101
this.log(`Deploy ID: ${chalk.bold(deployId)}`);
105102

106103
if (flags.async) {
@@ -109,6 +106,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
109106
return asyncFormatter.getJson();
110107
}
111108

109+
const mdapiDeploy = new MetadataApiDeploy({
110+
usernameOrConnection: connection,
111+
id: deployId,
112+
apiOptions: {
113+
rest: api === API['REST'],
114+
},
115+
});
112116
const result = await mdapiDeploy.pollStatus({
113117
frequency: Duration.seconds(1),
114118
timeout: flags.wait,

test/commands/deploy/metadata/quick.nut.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('deploy metadata quick NUTs', () => {
8282
});
8383

8484
describe('--job-id', () => {
85-
it('should deploy previously validated deployment', async () => {
85+
it('should deploy previously validated deployment (async)', async () => {
8686
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
8787
args: '--source-dir force-app',
8888
json: true,
@@ -97,6 +97,26 @@ describe('deploy metadata quick NUTs', () => {
9797
exitCode: 0,
9898
});
9999
assert(deploy);
100+
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
101+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
102+
});
103+
104+
it('should deploy previously validated deployment (poll)', async () => {
105+
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
106+
args: '--source-dir force-app',
107+
json: true,
108+
exitCode: 0,
109+
});
110+
assert(validation);
111+
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
112+
113+
const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
114+
args: `--job-id ${validation.result.id} --wait 20`,
115+
json: true,
116+
exitCode: 0,
117+
});
118+
assert(deploy);
119+
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
100120
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
101121
});
102122

0 commit comments

Comments
 (0)