function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anschoeweanschoewe 

Ant Migration Tool fails to deploy with Schedulable Classes

We recently started working with Scheduable Apex and batchable classes.  We rely heavilly on the Ant Migration Tool to enable our continuous integration tool Hudson to work with our Apex code.  Behind the scenes, it's calling the Salesforce Ant Migration Tool.  We also use the migration tool for deployment.

 

This was all working fine until we start wrting Scheduable classes.  Now, whenever we try to do a validate deployment using the migration tool (without tests running) I always get failures for a few classes.  The error message is always:

 

Batchable class has jobs pending or in progress; Schedulable class has jobs pending or in progress

 

I get this error message next to classes that aren't even scheduable classes.  I can however deploy fine from Eclipse.  I've also heard that change sets will work.  Has anyone else experienced this?  Is this a bug with the current Salesforce Ant Migration Tool?  Is there a workaround?  This is a huge problem for our team.  We rely on Hudson to validate our build every time we check in code to SVN.  Each time, it's telling us that the build failed.  Help please!!

 

Andrew

 

FYI.... I can run all the tests fine through the Salesforce UI and I don't receive any errors.  This seems to indicate that no sceduled Apex jobs are actually running.

 

Cory CowgillCory Cowgill

If you have a Scheduled Job which has code referenced you are deploying, it will fail with that error.

 

You need to remove the scheduled jobs (DELETE) from the Scheduled Jobs.

 

To confim / remove the scheduled jobs:

 

Setup -> Monitoring -> Scheduled Jobs

 

 

Cory CowgillCory Cowgill

Also you need to remove the Batch Jobs if any are queued or in progress.

 

Setup -> Monitoring -> Batch Jobs

anschoeweanschoewe

Both of your answers are very helpful.  Thank you.

 

I had stoped the scheduled jobs but I didn't think to look at the running Batch jobs on the 'Apex Jobs' page.

 

Unfortunately, this confirms my assumption that I can't really script deployments and utilize a continuous integration environment when our code utilizes Batch jobs and Schedulable jobs.  This seems little ridiculous since I'm just doing a 'validate deployment' 98% of the time.  I feel like I should be able to build the code without having to worry about what's scheduled or running.  Now, if I was doing an actual deployment I can understand why one might need to stop each of these running/scheduled jobs.  It's very frustrating and I wish Salesforce would acknowledge this problem.

 

Andrew

Cory CowgillCory Cowgill

Yeah I feel your pain.

 

Its also annoying that you can't just 'DeActivate' a Scheduled Job.

 

You have to actually delete it and recreate it which is inconvienient.

Ram G VittalRam G Vittal

I am having the same issue with ant migration tool. I have deleted the scheduled jobs and don't have any batch jobs queued or in progress for the batch schedulable apex class. But still the ant migration fails with Batchable class has jobs pending or in progress. Any ideas?