Find out how to use the gitversion/command task using the examples below.
Note that if the pipeline is set up to use a shallow git fetch mode the GitVersion Command task will fail. It is required to use fetchDepth: 0
.
You must also run the GitVersion Setup step before the Command step:
steps:
- checkout: self
fetchDepth: 0
- task: gitversion/[email protected]
displayName: Install GitVersion
inputs:
versionSpec: '6.3.x'
These steps are omitted from the examples for brevity.
The examples use version 3.2.1 of the GitVersion Command task. It is recommended to use the latest released version in your own workflows.
The Command GitVersion task accepts the following inputs:
targetPath:
description: Optionally supply the path to the working directory
required: false
default: ''
disableShallowCloneCheck:
description: Whether to disable the check for shallow clone
required: false
default: 'false'
arguments:
description: Arguments to send to GitVersion
required: true
default: ''
Show the effective configuration for GitVersion by running the /showConfig command.
steps:
# gitversion/[email protected] task omitted for brevity.
- task: gitversion/[email protected]
displayName: Display GitVersion config
inputs:
arguments: '/showConfig'
Outputs the FullSemVer variable by running the /showvariable FullSemVer command.
steps:
# gitversion/[email protected] task omitted for brevity.
- task: gitversion/[email protected]
displayName: Output the FullSemVer variable
inputs:
arguments: '/showvariable FullSemVer'
Outputs the formatted version by running the /format {Major}.{Minor} command.
steps:
# gitversion/[email protected] task omitted for brevity.
- task: gitversion/[email protected]
displayName: Output the formatted version
inputs:
arguments: '/format {Major}.{Minor}' # any Output Variable can be used here