It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do you deploy to Salesforce when you have scheduled apex jobs?

From this comment - 

I have been using SF migration tool, but encounter a road block: we have quite a few scheduled apex job in the system.  Although the jobs may not run, the migration tool will just error out.  Do you run into issue with schedule jobs?  If so, how do you resolve them?  Thx.

1 answer

2 votes

We have an apex class that we use to abort and schedule all jobs before and after deploys. We currently run this manually by calling the methods with anonymous apex (from the dev console or SoqlXplorer), but we would ideally build this in as a step in our Bamboo deployments.

public with sharing class ProcessScheduledJobs {
	public static void scheduleAll(){
		System.schedule('jobname1','0 0 2 ? * SAT', new SomeSchedulableClass());
		System.schedule('jobname2','0 1 * * * ?', new SomeOtherSchedulableClass());
	}

	public static void abortAll(){
		// CronJobDetail.JobType = '7' represents scheduled apex jobs
		for(CronTrigger ct : [SELECT Id FROM CronTrigger WHERE CronJobDetail.JobType = '7']){
			system.abortJob(ct.Id);
		}
	}
}

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted 9 hours ago in Industry Groups

Upcoming Team Tour Government Symposium in Washington D.C.

Calling all Community members from the Washington D.C. area! Atlassian’s Team Tour is heading to your city to host a Government Symposium on May 1st. Join our team and other government agencies to le...

14 views 0 1
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you