4

I have the following shell script:

sfdx force:org:create -f ./config/project-scratch-def.json -a ScratchOrg
sfdx force:package:install --package 04t0M000001mF9bQAE -u ScratchOrg 
sfdx force:package:install --package 04tG0000000LKgXIAW -u ScratchOrg 
sfdx force:package:install --package 04t58000000KnAkAAK -u ScratchOrg 
sfdx force:package:install --package 04t1Q000000lpP6QAI -u ScratchOrg
sfdx force:source:push -u ScratchOrg

However this fails because the push happens before the 4 packages have finished installing. Is there some way I can make this wait? Or better, include this information in my scratch org configuration?

1 Answer 1

5

Use the -w parameter so that each command waits for confirmation, and things proceed in order:

sfdx force:org:create -w 10 -s -f ./config/project-scratch-def.json -a ScratchOrg
sfdx force:package:install -w 10 --package 04t0M000001mF9bQAE
sfdx force:package:install -w 10 --package 04tG0000000LKgXIAW
sfdx force:package:install -w 10 --package 04t58000000KnAkAAK
sfdx force:package:install -w 10 --package 04t1Q000000lpP6QAI
sfdx force:source:push

The 10 here means 10 minutes. If you think you more time, feel free to increase the value. I usually use 99 minutes in my scripts, which should be plenty of time.

Also, note that you can use -s to set the default user name to the scratch org, which simplifies your commands.

I also prefer to use aliases for my packages:

sfdx force:package:install -w 10 --package "package A"
sfdx force:package:install -w 10 --package "package B"
sfdx force:package:install -w 10 --package "package C"
sfdx force:package:install -w 10 --package "package D"

This helps you when you need to update package IDs, as you can centralize the updates to your sfdx-project.json file.

2
  • Cheers! A few followup questions: 1. Is it safe to assume if it doesn't need 10 or 99 minutes, it won't keep waiting once the deployment is finished? 2. Is the alias the same as the package name in force:package:installed:list? Or where can I get those values? 3. What changes can/should I make to sfdx-project.json in order to centralize? Jul 3, 2020 at 16:14
  • 1
    @BrianKessler (1) Correct. It waits only until completion. The -w value is a maximum timeout. (2) No, it's in the packageAliases section of your sfdx-project.json. (3) See the project configuration page.
    – sfdcfox
    Jul 3, 2020 at 16:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .