Any package dependencies in sfdx-project.json file will mean that the yml file will not build the scratch org and fails
if a sfdx-project.json includes a set of dependencies in the packageDirectories then
{ "packageDirectories": [ { "path": "force-app", "default": true, "dependencies": [ { "subscriberPackageVersionId": "04t3h000004jpwzAAA" } ], "package": "LoggerTestPackage", "versionName": "ver 0.1", "versionNumber": "0.1.0.NEXT" } ], "namespace": "", "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "50.0", "packageAliases": { "LoggerTestPackage": "0Ho4J000000TNkxSAG" } }
The yml will not install the dependent packages and this means that the creation of the scracth org will fail on pushing source code.
I added a install_dependencies function in the deploy_scratch_org
function deploy_scratch_org() {
local devhub=$1
local orgname=$2
assert_within_limits $devhub DailyScratchOrgs
local scratch_org_username=$(create_scratch_org $devhub $orgname)
echo $scratch_org_username > SCRATCH_ORG_USERNAME.txt
get_org_auth_url $scratch_org_username > SCRATCH_ORG_AUTH_URL.txt
install_dependencies $scratch_org_username
push_to_scratch_org $scratch_org_username
populate_scratch_org_redirect_html $scratch_org_username
echo "Deployed to scratch org $username for $orgname"
}
#install_dependencies
#Arguments
#$1 = scratch org username
function install_dependencies() {
local scratch_org_username=$1
echo "Installing package dependencies"
for package_version_id in $(jq -r '.packageDirectories[].dependencies[].subscriberPackageVersionId' < sfdx-project.json)
do
echo $package_version_id
if [ $package_version_id ]; then
# install the package
local cmd="sfdx force:package:install --targetusername $scratch_org_username --package $package_version_id --wait 10 --publishwait 10 --noprompt --json" && (echo $cmd >&2)
local output=$($cmd) && (echo $output | jq '.' >&2)
fi
done
}
Edited by Andy Nix