Επεξεργασία

Κοινή χρήση μέσω


Ant@1 - Ant v1 task

Use this task to build with Apache Ant.

Syntax

# Ant v1
# Build with Apache Ant.
- task: Ant@1
  inputs:
    buildFile: 'build.xml' # string. Alias: antBuildFile. Required. Ant build file. Default: build.xml.
    #options: # string. Options. 
    #targets: # string. Target(s). 
  # JUnit Test Results
    #publishJUnitResults: true # boolean. Publish to Azure Pipelines. Default: true.
    testResultsFiles: '**/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOptions: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    codeCoverageClassFilesDirectories: '.' # string. Alias: classFilesDirectories. Required when codeCoverageTool != None. Class files directories. Default: ..
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool != None. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
  # Advanced
    #antHomeDirectory: # string. Alias: antHomeUserInputPath. Set ANT_HOME path. 
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkUserInputDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
# Ant v1
# Build with Apache Ant.
- task: Ant@1
  inputs:
    buildFile: 'build.xml' # string. Alias: antBuildFile. Required. Ant build file. Default: build.xml.
    #options: # string. Options. 
    #targets: # string. Target(s). 
  # JUnit Test Results
    #publishJUnitResults: true # boolean. Publish to Azure Pipelines/TFS. Default: true.
    testResultsFiles: '**/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOptions: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    codeCoverageClassFilesDirectories: '.' # string. Alias: classFilesDirectories. Required when codeCoverageTool != None. Class files directories. Default: ..
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool != None. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
  # Advanced
    #antHomeDirectory: # string. Alias: antHomeUserInputPath. Set ANT_HOME path. 
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkUserInputDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.

Inputs

buildFile - Ant build file
Input alias: antBuildFile. string. Required. Default value: build.xml.

The relative path from the repository root to the Ant build file.

For more information about build files, see Using Apache Ant.


options - Options
string.

Provides options 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)
string.

An optional, space-separated list of targets to build. If not specified, the default target will be used. If no default target is defined, Ant 1.6.0 and later will build all top-level tasks.

See Using Apache Ant Targets.


publishJUnitResults - Publish to Azure Pipelines
boolean. Default value: true.

Select this option to publish JUnit test results produced by the Ant build to Azure Pipelines. Each test results file matching Test Results Files will be published as a test run in Azure Pipelines.


publishJUnitResults - Publish to Azure Pipelines/TFS
boolean. Default value: true.

Select this option to publish JUnit test results produced by the Ant build to Azure Pipelines. Each test results file matching Test Results Files will be published as a test run in Azure Pipelines.


testResultsFiles - Test results files
string. Required when publishJUnitResults = true. Default value: **/TEST-*.xml.

The test results file path. Wildcards can be used. For more information, see the file matching patterns reference. For example, **/TEST-*.xml for all XML files whose name starts with TEST-.


testRunTitle - Test run title
string. Optional. Use when publishJUnitResults = true.

Provides a name for the test run.


codeCoverageToolOptions - Code coverage tool
Input alias: codeCoverageTool. string. Allowed values: None, Cobertura, JaCoCo. Default value: None.

Selects the code coverage tool.

If you are using the Microsoft-hosted agents, then the tools are set up for you. If you are using the on-premises Windows agent, you must ensure the agent is set up for either JaCoco or Cobertura.

  • JaCoCo - ensure that jacocoant.jar is available in the lib folder of Ant installation. Learn more about JaCoCo Ant tasks.
  • Cobertura - ensure that an environment variable COBERTURA_HOME points to the Cobertura .jar files location. Learn more about Cobertura with Ant tasks.

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


codeCoverageClassFilesDirectories - Class files directories
Input alias: classFilesDirectories. string. Required when codeCoverageTool != None. Default value: ..

The comma-separated list of relative paths from the Ant build file to directories containing class files and archive files (.jar, .war, etc.). Code coverage is reported for class files in these directories. For example: target/classes,target/testClasses.


codeCoverageClassFilter - Class inclusion/exclusion filters
Input alias: classFilter. string. Optional. Use when codeCoverageTool != None.

The comma-separated list of filters to include or exclude classes from collecting code coverage. For example: +:com., +:org., -:my.app*..


codeCoverageSourceDirectories - Source files directories
Input alias: srcDirectories. string. Optional. Use when codeCoverageTool != None.

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


codeCoverageFailIfEmpty - Fail when code coverage results are missing
Input alias: failIfCoverageEmpty. boolean. Optional. Use when codeCoverageTool != None. Default value: false.

Fails the build if the code coverage did not produce any results to publish.


antHomeDirectory - Set ANT_HOME path
Input alias: antHomeUserInputPath. string.

If set, overrides any existing ANT_HOME environment variable with the given path.


javaHomeOption - Set JAVA_HOME by
Input alias: javaHomeSelection. string. Required. Allowed values: JDKVersion (JDK Version), Path. Default value: JDKVersion.

Sets JAVA_HOME either by selecting a JDK version that will be discovered during builds or by manually entering a JDK path.


jdkVersionOption - JDK version
Input alias: jdkVersion. string. Optional. Use when javaHomeSelection = JDKVersion. Allowed values: default, 1.11 (JDK 11), 1.10 (JDK 10 (out of support)), 1.9 (JDK 9 (out of support)), 1.8 (JDK 8), 1.7 (JDK 7), 1.6 (JDK 6 (out of support)). Default value: default.

Attempts to discover the path to the selected JDK version and sets JAVA_HOME accordingly.


jdkUserInputDirectory - JDK path
Input alias: jdkUserInputPath. string. Required when javaHomeSelection = Path.

Sets JAVA_HOME to the given path.


jdkArchitectureOption - JDK architecture
Input alias: jdkArchitecture. string. Optional. Use when jdkVersion != default. Allowed values: x86, x64. Default value: x64.

Optionally supplies the architecture (x86, x64) of the JDK.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Use this task to build with Apache Ant.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: ant
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 1.89.0 or greater
Task category Build