While deploying the code to Production all tests except of Managed
Package will be executed regardless of the "runalltests" value, is
this not the case with Sandbox?
That is not correct. All unmanaged tests will run when deploying to a production org, regardless of the runalltests
flag. The managed package tests only run if runalltests
is set to true.
The SalesForce help explains it as:
In Production - if set to false, then managed package tests will not
run but every other test will run.
In Sandbox - if set to false, no tests will run.
So to summerize:
- Setting
runalltests
to true will run all tests (managed/unmanaged) in all orgs
- Setting
runalltests
to false will stop all tests (managed/unmanaged) from running in all orgs except for production where the unmanaged tests will always run
The error log shows a number of errors in the metadata you're trying to deploy through the Metadata API which the Force.com Ant Migration Tool ultimately calls. My hunch is that a full save to server from Force IDE would get the same errors.
One thing I've noticed about deployment logs is that you can often ignore the massive number of duplicate lines. For example, the following error appears all over your log:
Error: Required field is missing: type
It's likely that a previous failure is causing this error and fixing the other failures will make this one go away. So, going with that strategy, there are a few errors you need to fix in the metadata files to get the deployment to pass:
[sf:deploy] 1. settings/Account.settings -- Error: You cannot disable account teams using the Metadata API. Your system administrator can disable account teams from the Account Team Setup page.
Account Teams are not supported for deployment through the Metadata API:
http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_unsupported_types.htm
[sf:deploy] 2. objects/AccountContactRole.object -- Error: ControlledByParent is not a valid sharing model for AccountContactRole
Adjust the sharing model of AccountContactRole.object or if you didn't make any customizations to it, delete the file locally so it's not a part of your deployment.
[sf:deploy] 3. objects/Site.object -- Error: Entity cannot be untracked.
This is likely due to the same issue with the same fix as discussed here:
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008k09IAA
[sf:deploy] 163. objects/Contract.object (Contract.APXTConga4__Conga_Mail_Merge) -- Error: Cannot create a new component with the namespace: APXTConga4. Only components in the same namespace as the organization can be created through the API (line 235, column 15)
...
[sf:deploy] 171. objects/Solution.object (Solution.APXTConga4__Conga_Mail_Merge) -- Error: Cannot create a new component with the namespace: APXTConga4. Only components in the same namespace as the organization can be created through the API (line 120, column 15)
These errors indicate that you're trying to deploy metadata which comes from the APXTConga4 package. You can only deploy managed page components by installing the managed package. There is a trick you can do via the migration tool to install managed packages into the org as a separate deployment but covering that is beyond this question.
Edit the offending objects and remove any metadata starting with APXTConga4__
Finally, I wanted to point to another option I've been working with lately. You can create an unmanaged package in your sandbox org (Setup -> Create -> Packages) and then add all the custom code you want to migrate to it. Then you can use Ant to pull down only the metadata you chose to include in that package. This approach helps you avoid a lot of the issues you're seeing as it doesn't pull down anything from standard salesforce or installed packages, only the code you explicitly tell it to include. I plan to write a blog post on this approach soon, but you can get some more details from this answer I posted a few months back:
Using sf:bulkRetrieve do not fetch metadata components associated with a managed package
Best Answer
For adding things to a package.xml file, you need two pieces of information:
For finding the metadata type name, I find the metadata api types documentation to be a good resource.
The metadata type name is exactly what you use in between
<name></name>
in your package.xml file, and I believe it works for everything except the metadata types listed in unsupported metadata types. In this case, if you want to deploy an entire workflow, the metadata type name that you'd use isWorkflow
Although the documentation only provides one example (which is rather unfortunate, I think), the general format that you'll use for including a workflow in a package.xml file is documented on the documentation for the Workflow metadata type
Finding the fully qualified name is a bit trickier. For some metadata items, like Apex Classes, it's simply the name of the thing you want to deploy. For others, like fields or validation rules on an object, you use the object name as a prefix. In rarer cases, like email templates and reports which can be organized into folders, you need to use the folder names and forward slashes much like you'd do if you were typing a url.
For workflow, the fully qualified name is the API name of the object the workflow is for. Adding this to a package.xml file would look like this:
To me, this makes sense because the current structure of Salesforce's metadata includes workflow as part of the metadata forCustomObject
(which contrary to its name encompasses both standard and custom sObjects). If you dive into the metadata that gets retrieved when you retrieve nothing but workflows, you'll notice that the folder structure you get isinstead of
+edit: after taking a second look, I don't believe the above is true for Workflow, it is true for other things like
ValidationRule
though. Workflow is tied to an sObject though, so using it as the fully qualified name still makes sense to me here.As the documentation notes, the
Workflow
metadata type itself can contain other metadata types, and you can use these to deploy individual workflow rules (WorkflowRule
), email alerts (WorkflowAlert
), field updates (WorkflowFieldUpdate
), etc...The fully qualified name for individual parts of a workflow use the API name of the object the overall workflow is on, a dot (period/full-stop), and the API name of the workflow component that you want to retrieve/deploy.
An example is:
It should be noted that you may run into issues deploying individual parts of a workflow rule, because the order in which things does matter (the workflow needs to exist before you can add/change/remove rules, field updates etc...)