Skip to content

Instantly share code, notes, and snippets.

@cyan198
Last active July 15, 2019 14:30
Show Gist options
  • Save cyan198/9acda961e882abe6e9a994d67555fe8b to your computer and use it in GitHub Desktop.
Save cyan198/9acda961e882abe6e9a994d67555fe8b to your computer and use it in GitHub Desktop.
Azure pipeline Yaml definition to generate semantic version for dotnet project and save it to var group for other other pipelines use
trigger:
- master
jobs:
- job: determine_ver
pool:
# vmImage: 'Ubuntu-16.04'
vmImage: 'windows-2019'
steps:
- checkout: self
persistCredentials: true
clean: true
- task: GitVersion@4
displayName: 'GitVersion'
inputs:
updateAssemblyInfo: true
- powershell: echo "##vso[task.setvariable variable=semVersion;isOutput=true]'$(GitVersion.SemVer)'"
name: setvarStep
- script: echo %Action%%BuildVersion%
displayName: 'Set build version'
env:
Action: '##vso[build.updatebuildnumber]'
BuildVersion: $(GitVersion.SemVer)
- job: update_var_group
dependsOn: determine_ver
pool: server
variables:
semVersion: $[ dependencies.determine_ver.outputs['setvarStep.semVersion'] ]
steps:
- task: InvokeRESTAPI@1
inputs:
connectionType: 'connectedServiceName'
serviceConnection: 'DevOps REST API'
method: 'PUT'
body: '{"type":"Vsts","name":"your-var-group-name","variables":{"your-var-name":{"isSecret":false,"value": $(semVersion) }}}'
urlSuffix: 'yourOrg/yourProject/_apis/distributedtask/variablegroups/{replace-with-variableGroupId}?api-version=5.0-preview.1'
waitForCompletion: 'false'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment