Skip to content

Commit

Permalink
Merge pull request #1604 from SalesforceFoundation/feature/cancel-sch…
Browse files Browse the repository at this point in the history
…edules

Cancel Scheduled Jobs for Dev Config
  • Loading branch information
MatthewBlanski authored Mar 24, 2021
2 parents ba214cc + 6e1bbd6 commit 6ec8d0e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,15 @@ tasks:
options:
command: "force:user:permset:assign -n Encryption"

cancel_eda_scheduled_jobs:
description: Unscheduleds EDA Apex jobs
class_path: cumulusci.tasks.apex.anon.AnonymousApexTask
options:
path: scripts/schedule.cls
apex: cancelScheduledJobs();

check_translation_workbench_enabled:
group: "EDA Metadata"
group: "EDA: Metadata"
description: Detects whether or not translation workbench is enabled
class_path: cumulusci.tasks.preflight.settings.CheckSettingsValue
options:
Expand Down Expand Up @@ -371,10 +378,12 @@ flows:
3:
task: execute_install_apex
4:
task: deploy_dev_config
task: cancel_eda_scheduled_jobs
5:
flow: run_unmanaged_unit_tests
task: deploy_dev_config
6:
flow: run_unmanaged_unit_tests
7:
flow: eda_settings_unmanaged

config_dev_namespaced:
Expand Down Expand Up @@ -531,11 +540,6 @@ flows:
- when: "not tasks.check_translation_workbench_enabled()"
action: hide

qa_org_2gp:
steps:
2:
flow: config_2gp

run_unmanaged_unit_tests:
# description: Configure an org for use as a dev org after package metadata is deployed.
steps:
Expand Down
34 changes: 34 additions & 0 deletions scripts/schedule.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
public static void cancelScheduledJobs() {
List<String> edaScheduledJobs =
new List<String>{
'Seasonal Addresses Update',
'HEDA Async Apex Error Processing',
'HEDA 90-day-old Error Cleaning'
};

List<CronJobDetail> edaCronJobDetailList = [
SELECT Id,
Name,
JobType
FROM CronJobDetail
WHERE Name IN: edaScheduledJobs
];

if(edaCronJobDetailList.isEmpty()) {
return;
}

List<CronTrigger> edaCronTriggerList = [
SELECT Id
FROM CronTrigger
WHERE CronJobDetailId IN: edaCronJobDetailList
];

if(edaCronTriggerList.isEmpty()) {
return;
}

for(CronTrigger cronTrigger : edaCronTriggerList) {
System.abortJob(cronTrigger.Id);
}
}

0 comments on commit 6ec8d0e

Please sign in to comment.