You can use the Team Foundation Server task to connect to the Team Foundation Server and invoke configured build and test jobs.

Prerequisites

  • Verify that the Team Foundation Server endpoint is registered. See the Installation and Configuration guide.

  • Verify that the Team Foundation Server project collection, team projects, and build definitions are configured.

Procedure

  1. Click the Code Stream tab.
  2. Select an existing pipeline to configure from the Pipeline tab.
  3. Select Edit > Stages.
  4. Select Add Task.
  5. Select Custom from the Category drop-down menu.
  6. Select TFS from the Provider drop-down menu.
  7. Select the Team Foundation Server endpoint you registered from the drop-down menu.
  8. Enter a name for the custom task and click OK.
  9. Select the new task from the stage column.
  10. Confirm to save the pipeline.
  11. Select an Execute Task for the release pipeline.

    Option

    Description

    Always

    Runs the release pipeline task without conditions.

    On Condition(s)

    Runs the release pipeline task only if the defined condition is evaluated as true. If the condition is false, the task is skipped.

    A boolean expression using the following operands and operators is supported.

    • Pipeline variables such as, ${pipeline.variableName}. Curly brackets are reserved for specifying pipeline variables.

    • Task output variables such as, ${Stage1.task1.machines.value.hostIp}

    • Default pipeline constant variables such as, ${releasePipelineName}

    • Case insensitive Boolean values such as, true, false, 'true', 'false'

    • Integer or decimal values without quotes

    • String values used with single or double quotes such as, "test", 'test'

    • String and Numeric types of values such as, == Equals and != Not Equals

    • Relational operators such as, > , >=, <, and <=

    • Boolean logic such as, && and ||

    • Arithmetic operators such as, +, -, *, and /

    • Nested expressions using round brackets

    • Strings with literal value ABCD is evaluated as false and the task is skipped.

    Unary operators are not supported.

    A sample condition, ${Stage1.task1.output} == “Passed” || ${pipeline.variableName} == 39

  12. (Optional) : Select the Continue Pipeline execution even if this task fails option.

    This option allows the release pipeline to bypass the failed task and continue with the execution process.

  13. Configure the Team Foundation Server properties.

    Option

    Description

    Project Collection

    Provides a list of existing Team Foundation Server project collections.

    Team Project

    Lists the existing team projects on the Team Foundation Server.

    Build Priority

    Defines the level of priority on when the build runs.

    Build Definition

    Provides a search capability for build definitions with automatic complete.

    When you select the build definition the associated arguments and properties are populated from Team Foundation Server.

  14. Select one or more Team Foundation Server job output properties to expose to other tasks in the release pipeline.

    For example, you can expose the Team Foundation Server build ID and build URL in a deploy task.

Task Output Format for a Team Foundation Server

The following task output format is an example for a Team Foundation Server task.

[
    {
        "name": "buildId",
        "displayName": "Build Id",
        "value": "823",
        "displayValue": null
    },
    {
        "name": "dropLocation",
        "displayName": "Drop Location",
        "value": "#/70869/drop",
        "displayValue": null
    },
    {
        "name": "logUrl",
        "displayName": "Build Summary Url",
        "value": "http://19.126.10.35:8080/tfs/TFSTestCollection/ConsoleApplication/_build#buildUri=vstfs:///Build/Build/893&_a=summary",
        "displayValue": "http://19.126.10.35:8080/tfs/TFSTestCollection/ConsoleApplication/summary"
    },
    {
        "name": "buildUrl",
        "displayName": "Build Summary Url",
        "value": "http://19.126.10.35:8080/tfs/TFSTestCollection/ConsoleApplication/_build#buildUri=vstfs:///Build/Build/893&_a=summary",
        "displayValue": "http://19.126.10.35:8080/tfs/TFSTestCollection/ConsoleApplication/summary"
    },
    {
        "name": "failedTestsCount",
        "displayName": "Number Of Failed Tests",
        "value": "3",
        "displayValue": null
    }
]