Run an Apex script
Run an Apex script
One of the types of deployment actions, YAML type: apex. That page explains what all types share: when actions run, how to choose their target orgs, how they are tracked and how to recover a failed one.
Executes one of the .apex script files of your project against the target org. Useful for initialization scripts or migrations, like assigning permission sets or recalculating fields.
Technical: apex action (YAML)
Executes an Apex script file against the target org using sf apex run --file.
| Custom parameter | Description | Example |
|---|---|---|
parameters.apexScript |
Relative path to the .apex script file in the repository. |
scripts/apex/init.apex |
- id: 00de1479-8639-46a2-96e1-88cfa69be4db
label: Run initialization apex
type: apex
parameters:
apexScript: scripts/apex/init.apex
context: process-deployment-only
Learn by doing
The free Salesforce DevOps with sfdx-hardis course does this, click by click, on an org of your own:
