Build & Install an Artifact

In the earlier section, we looked at how we configured the project directory for sfp, Now lets walk through some core commands.

A. Build an artifact for a package

The build command will generate a zipped artifact file for each package you have defined in the sfdx-project.json file. The artifact file will contain metadata and the source code at the point build creation for you to use to install.

  1. Open up a terminal within your Salesforce project directory and enter the following command:

sfp build -v <DevHubAlias/DevHubUsername>

You will see the logs with details of your package creation, for instance here is a sample output

  1. A new "artifacts" folder will be generated within your source project containing a zipped artifact file for each package defined in your sfdx-project.json file. For example, the artifact files will contain the following naming convention with the "_sfpowerscript_artifact_" in between the package name and version number.

B. Install the artifact to a target org

Ensure you have authenticated your salesforce cli to a org first. If you haven't, please find the instructions here.

  1. Once you have the authenticated to the sandbox, you could execute the installation command as below

sfp install -o <TargetOrgAlias/TargetOrgUsername>
  1. Navigate to your target org and confirm that the package is now installed with the expected changes from your artifact. In this example above, a new custom field has been added to the Account Standard Object.

Depending on the type of packages, sfp will issue the equivalent test classes with in the package directory and it could result in failures during installation, Please fix the issues in your code and repeat till you get a sucessful installation. If your packages doesn't have sufficient test coverage, you may need to use the all tests in the org to get your package installed. Refer to the material here

Last updated