dxatscale / sfpowerscripts

A build system for modular development in Salesforce
https://dxatscale.io
MIT License
213 stars 96 forks source link

sfdx sfpowerscripts:dependency:install fails when used with Prepare command #1276

Open petter-eikeland opened 1 year ago

petter-eikeland commented 1 year ago

Describe the bug Trying to create a pool of scratch orgs with all external dependencies, and some packages. Currently I'm using the releaseConfigFile parameter to specify the packages I want installed. However, I had some issues specifying external dependencies in the releaseConfigFile. Thus, I tried adding the sfdx sfpowerscripts:dependency:install command using either the preDependencyInstallationScriptPath & postDeploymentScriptPath commands. This command successfully installs all external dependencies, but it fails as it messes up the prepare logs (see screenshots below).

I might be looking in the wrong direction, and could be that the releaseConfigFile parameter should also help resolve external dependencies? I have tried using the includeOnlyPackageDependencies & packageDependencies parameters in the releaseConfig YAML file. But this did not make the Prepare command install the external dependencies.

To Reproduce

  1. Create a new Prepare pipeline. Use releaseConfigFile parameter to install the packages that you want:
# List of packages that should be installed
release: "test-pool"
includeOnlyArtifacts:
  #-------------- Framework Packages------------#
  - nebula-logger-core
  - trigger-actions-framework

  #-------------- Core Packages------------#
  - core-components

  #-------------- Managed Dependencies ------------#

packageDependencies:
  - EDA@1.120.0.2
  - Marketing Cloud@240.0.0.2

includeOnlyPackageDependencies:
  - bicx-core  # Has EDA & MC as dependency in sfdx-project.json
  1. Add sfdx sfpowerscripts:dependency:install command as a preDependencyInstallationScriptPath or postDeploymentScriptPath.
  2. Run the Prepare Pipeline

Expected behavior Pool is successfully created without any errors. External dependencies are installed either by using includeOnlyPackageDependencies or packageDependencies parameters OR by using sfdx sfpowerscripts:dependency:install in a preDependencyInstallationScriptPath or postDeploymentScriptPath

Screenshots image

Platform Details (please complete the following information): OS: Linux Version [e.g. CLI Version eg: 1.6.6] LATEST (20.26.3) Salesforce CLI(sfdx cli) Version: 7.186.2 CI Platform: Azure DevOps

azlam-abdulsalam commented 1 year ago

@petter-eikeland when you use includeOnlyArtifacts. didn't it automatically install the dependency of the filtered artifacts?

petter-eikeland commented 1 year ago

@azlam-abdulsalam includeOnlyArtifacts: installs both the packages and dependencies of those packages automatically yes. But I want a pool with all external dependencies of the repo installed, but not all packages. E.g. I want all the external dependencies of the bicx-core package to be installed, but not deploy bicx-core if that makes sense? I thought perhaps the includeOnlyPackageDependencies is used for this?

azlam-abdulsalam commented 1 year ago

it doesn't at the moment ☺️, missed the scenario!

This is more towards creation of the release definition where you have an option to install dependencies.

Will address this as a bug

azlam-abdulsalam commented 1 year ago

now for the install dependency command when used directly, can you help me how did you set up the script?

petter-eikeland commented 1 year ago

Awesome! Thx for such swift help.

For the install dependency command, I did the following:

  1. Create a installPreDependencies.sh bash script for executing the dependency install script for all prepared scratch orgs:

    #!/bin/bash
    # Install all external dependencies
    sfdx sfpowerscripts dependency install -u $1 -v $2
  2. Create release config for pool:

    # List of packages that should be installed
    release: "test-pool"
    includeOnlyArtifacts:
    #-------------- Framework Packages------------#
    - nebula-logger-core
    - trigger-actions-framework
    
    #-------------- Core Packages------------#
    - core-components
  3. Create Config File for pool

{ "$schema": "https://raw.githubusercontent.com/Accenture/sfpowerscripts/develop/packages/sfpowerscripts-cli/resources/schemas/pooldefinition.schema.json", "tag": "bicx-validate", "maxAllocation": 20, "expiry": 1, "batchSize": 10, "configFilePath": "config/project-scratch-def.json", "enableSourceTracking": false, "succeedOnDeploymentErrors": false, "installAll": true, "releaseConfigFile": ".azure-pipelines/release-definitions/pool/bicx-pool-preinstalled-packages.yml", "preDependencyInstallationScriptPath":"./.azure-pipelines/scripts/installPreDependencies.sh", "fetchArtifacts": { "npm": { "scope": "@org" } } }



4. Run `sfdx sfpowerscripts:orchestrator:prepare -f config/bicx-pool-def.json -v devhub --npmrcpath $(npmrc.secureFilePath)`