The Force.com Migration Tool provides the deploy task, which can be incorporated into your deployment
scripts. You can modify the build.xml sample to include your organization's
classes and triggers. For a complete list of properties for the deploy task, see the Force.com Migration Tool
Guide. Some properties of the deploy task
are:
- username
- The username for logging into the Salesforce production
organization.
- password
- The password associated for logging into the Salesforce production
organization.
- serverURL
- The URL for the Salesforce server
you are logging into. If you do not specify a value, the default is www.salesforce.com.
- deployRoot
- The local directory that contains the Apex classes and triggers, as well as any other metadata, that you want
to deploy. The best way to create the necessary file structure is
to retrieve it from your organization or sandbox.
See Understanding retrieve for more information.
-
Apex class files must be in a subdirectory named classes.
You must have two files for each class, named as follows:
-
classname.cls
-
classname.cls-meta.xml
For example, MyClass.cls and MyClass.cls-meta.xml.
The -meta.xml file contains the API version
and the status (active/inactive) of the class.
-
Apex trigger files must be in a subdirectory named triggers. You must have two files for each trigger, named as follows:
-
triggername.trigger
-
triggername.trigger-meta.xml
For example, MyTrigger.trigger and MyTrigger.trigger-meta.xml. The -meta.xml file contains the API version
and the status (active/inactive) of the trigger.
- The root directory contains an XML file package.xml that lists all the classes, triggers, and other objects to be deployed.
- The root directory optionally contains an XML file destructiveChanges.xml that lists all the classes, triggers, and other objects to be deleted
from your organization.
- checkOnly
- Specifies whether the classes and triggers are deployed to the
target environment or not. This property takes a Boolean value: true if you do not want to save the
classes and triggers to the organization, false otherwise. If you do not specify a value, the default
is false.
- runTest
-
Optional child elements. A list of Apex classes containing
tests run after deploy.
To use this option, set testLevel to
RunSpecifiedTests.
- testLevel
-
Optional. Specifies which tests are run as part of a deployment.
The test level is enforced regardless of the types of components that are present in the
deployment package. Valid values are:
-
NoTestRun—No tests are run. This test level
applies only to deployments to development environments, such as sandbox, Developer
Edition, or trial organizations. This test level is the default for development
environments.
-
RunSpecifiedTests—Only the tests that you
specify in the runTests option are run. Code coverage requirements
differ from the default coverage requirements when using this test level. Each class and
trigger in the deployment package must be covered by the executed tests for a minimum of
75% code coverage. This coverage is computed for each class and trigger individually and
is different than the overall coverage percentage.
-
RunLocalTests—All tests in your organization
are run, except the ones that originate from installed managed packages. This test level
is the default for production deployments that include Apex classes or triggers.
-
RunAllTestsInOrg—All tests are run. The
tests include all tests in your organization, including tests of managed packages.
If you don’t
specify a test level, the default test execution behavior is used. See “Running Tests in a Deployment” in the Metadata API Developer’s Guide.
This field is available in API version 34.0 and later.
- runAllTests
- (Deprecated and available only in API version 33.0 and
earlier.) This parameter is optional and defaults to false. Set to true to run all Apex tests after
deployment, including tests that originate from installed managed
packages.