Skip to content

Allow deployment with pending Apex Jobs

Detection

  • String: You can bypass this error by allowing deployments with Apex jobs in the Deployment Settings page in Setup.

Examples

  • Error AccountBatch This Apex class has batch or future jobs pending or in progress. You can bypass this error by allowing deployments with Apex jobs in the Deployment Settings page in Setup.

Resolution

Apex jobs (batch, queueable, scheduled) of the target org use classes of the deployment.
- Allow it in the target org: Setup -> Deployment Settings -> "Allow deployments of components when corresponding Apex jobs are pending or in progress"
- The manual deployment action below reminds to do it in each org of the pipeline, with a checkbox in the Pull Request comments

Deployment action

A deployment action can solve this error. Create it on the Pull Request of the current branch:

sf hardis:project:action:create --agent --scope pr --pr-id current --when pre-deploy --type manual --label "Allow deployments with pending Apex jobs" --instructions "1. Open Setup, type Deployment Settings in the Quick Find box, and open Deployment Settings
2. Check \"Allow deployments of components when corresponding Apex jobs are pending or in progress\", then Save
3. If it is already checked, there is nothing to do"

Documentation: https://sfdx-hardis.cloudity.com/salesforce-devops-work-on-user-story-deployment-actions-manual/

Comments