Organization lock when performing a multistage deployment through the ANT deployment tool
|Knowledge Article Number||000232368|
|Description||When performing a multistage deployment through ANT, you might find that one or more tasks fail to deploy with:
"Admin operation already in progress"
"The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later."
This occurs when a change is requested on part of an organization that has been locked by a previous change which is still ongoing. This functionality is by design and is in place to ensure data integrity. More information on this can be found in the following Help & Training article: Why do I receive an 'Org Administration Locked' message?
|Resolution||Below is a suggested workaround to allow your multistage deployment to complete without experiencing a lock. Using the ANT sleep task, you can create a time after a request to allow all of the changes in the organization to complete before the next request occurs.
<target name="deploy"> <antcall target="firstAction" /> <sleep minutes="5"/> <antcall target="secondAction"/> </target>
You can refer to the ANT documentation for more on this task: https://ant.apache.org/manual/Tasks/sleep.html
The time that you'll need in your sleep task depends on what the request before it requires your organization to complete. Further to that, metadata deployments are asynchronous by nature. So it will take some testing to know how long this sleep task will need to be and you may need to add extra time to ensure you never experience an organization lock.
Please note, Salesforce does not support ANT as a whole and the above is solely a suggested workaround.