Skip to content
rfennell edited this page Aug 12, 2019 · 13 revisions

A set of tasks to manage builds, it is assumed these tasks will usually be called from a release pipeline.

Included Tasks

Build Retension Task

This task sets the 'keep forever' retension flag on a build. It takes one parameter, the build selection mode, set to either:

  • Select only the primary build associated with the release (default)
  • All the build artifacts associated with the release
  • A comma separated list of build artifacts

As of 1.7.x you also get the option to choose to set or unset the retension to allow rollback scenarios

There is also an advanced option

  • (Advanced) Use use build agents default credentials as opposed to agent token - usually only every needed for TFS usage

Get Build Variable Task

This task gets the value of a specified variable from a build definition, then publishes the value to a local variable from the current build/release.

  • The build definition id must be supplied.
  • The name of the variable to get
  • The local variable which is updated. Note that this is only updated to the scope of the current build or release. Not the definition

Update Build Variable Task

This task allows a variable to be set in a build definition.

The prime use of this task is envisaged to be the updating of a variable that specifies a version number that needs to be incremented when a release to production occurs.

It uses the following parameters

  • Build selection mode
    • Only the primary build associated with the release (default)
    • All the build artifacts associated with the release
    • A comma separated list of build artifacts
  • Variable name to update
  • Method to update the variable
    • Auto-increment the variable (default)
    • Specify a value
  • Value if not set to auto-increment
  • (Advanced) Use use build agents default credentials as opposed to agent token - usually only every needed for TFS usage

Important: The default rights of a build agent running a release is to not have the permission to edit the build definition (for pipeline variables) or the variable group (for variable group variables). If this task is used without altering these appropriate permission you will get an error from the following list

Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (403) Forbidden." ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Cannot update the variable group ... ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Cannot update the build definition ...

To address this problem you need to grant rights

For Pipeline Variables

Add permission to edit the build definition

  1. In a browser select the Pipeline tab
  2. Select the folder view
  3. Click the ... on the right and select Security
  4. Pick the user

For Variables Groups

Notes: Note supported in TFS 2017 due to lack of API calls

Add permission to edit the variable group definition

  1. In a browser select the Library tab
  2. Edit the required variable group
  3. Select the security tab
  4. Pick (or add) the user
  1. Save the changes
Clone this wiki locally