다음을 통해 공유


Ant task

TFS 2017 | TFS 2015

Use this task to build with Apache Ant.

Demands

The build agent must have the following capability:

  • Apache Ant

Arguments

Argument Description
antBuildFile
Ant build file
(Required) Relative path from the repository root to the Ant build file.
For more information about build files, see Using Apache Ant
Default value: build.xml
Argument aliases: buildFile
options
Options
(Optional) Options that you want to pass to the Ant command line. You can provide your own properties (for example, -DmyProperty=myPropertyValue) and also use built-in variables (for example, -DcollectionId=$(system.collectionId)). Alternatively, the built-in variables are already set as environment variables during the build and can be passed directly (for example, -DcollectionIdAsEnvVar=%SYSTEM_COLLECTIONID%).

See Running Apache Ant.

targets
Target(s)
(Optional) Target(s) for Ant to execute for this build.

See Using Apache Ant Targets.

JUnit test results options

Argument Description
publishJUnitResults
Publish to Azure Pipelines
(Required) Select this option to publish JUnit test results produced by the Ant build to Azure Pipelines or your on-premises Team Foundation Server. Each test result file that matches Test Results Files is published as a test run.
Default value: true
testResultsFiles
Test Results Files
(Required) Test results files path. Wildcards can be used. For example, */TEST-.xml for all xml files whose name starts with TEST-."
Default value: **/TEST-*.xml
testRunTitle
Test Run Title
(Optional) Assign a title for the JUnit test case results for this build.

Code coverage options

Argument Description
codeCoverageTool
Code Coverage Tool

(Optional) Select the code coverage tool you want to use.

If you are using the Microsoft-hosted agents, then the tools are set up for you. If you are using on-premises Windows agent, then if you select:

  • JaCoCo, make sure jacocoant.jar is available in lib folder of Ant installation. See JaCoCo.
  • Cobertura, set up an environment variable COBERTURA_HOME pointing to the Cobertura .jar files location. See Cobertura.

After you select one of these tools, the following arguments appear.


Default value: None
Argument aliases: codeCoverageToolOptions
classFilesDirectories
Class Files Directories

(Required) Specify a comma-separated list of relative paths from the Ant build file to the directories that contain your .class files, archive files (such as .jar and .war). Code coverage is reported for class files present in the directories. Directories and archives are searched recursively for class files.
For example: target/classes,target/testClasses.


Default value: .
Argument aliases: codeCoverageClassFilesDirectories
classFilter
Class Inclusion/Exclusion Filters

(Optional) Specify a comma-separated list of filters to include or exclude classes from collecting code coverage. For example: +:com.,+:org.,-:my.app.


Argument aliases: codeCoverageClassFilter
srcDirectories
Source Files Directories

(Optional) Specify a comma-separated list of relative paths from the Ant build file to your source directories. Code coverage reports will use these paths to highlight source code. For example: src/java,src/Test.


Argument aliases: codeCoverageSourceDirectories
failIfCoverageEmpty
Fail when code coverage results are missing

(Optional) Fail the build if code coverage did not produce any results to publish


Default value: false
Argument aliases: codeCoverageFailIfEmpty

Advanced options

Argument Description
antHomeUserInputPath
Set ANT_HOME Path
(Optional) If set, overrides any existing ANT_HOME environment variable with the given path.
Argument aliases: antHomeDirectory
javaHomeSelection
Set JAVA_HOME by
(Required) Sets JAVA_HOME either by selecting a JDK version that will be discovered during builds or by manually entering a JDK path.
Default value: JDKVersion
Argument aliases: javaHomeOption
jdkVersion
JDK version
(Optional) Will attempt to discover the path to the selected JDK version and set JAVA_HOME accordingly.
Default value: default
Argument aliases: jdkVersionOption
jdkUserInputPath
JDK Path
(Required) Sets JAVA_HOME to the given path
Argument aliases: jdkUserInputDirectory
jdkArchitecture
JDK Architecture
(Optional) Optionally supply the architecture (x86, x64) of the JDK.
Default value: x64
Argument aliases: jdkArchitectureOption

Task control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

FAQ

Do I need an agent?

You need at least one agent to run your build or release.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.