2 Answers

2
votes

I used the following in my .vsts-ci

- task: Npm@1
  displayName: 'npm run build'
  inputs:
    command: custom
    verbose: false
    customCommand: 'run build'
- task: Npm@1
  displayName: 'npm publish'
  inputs:
    command: custom
    verbose: false
    customCommand: 'publish'
    condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))

Specifically the condition you need to put in your control block is

and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) for v* but you can change that to something else

1
votes

When I want VSTS to build on git tag pattern I do this

refs/tags/v*

will build for git tags 'v1.2.3'

For all tags:

refs/tags/*

I use this in conjunction with GitVersion.

EDIT: I should have said that this is added to the Build Pipeline BRANCH FILTERS trigger. When you specify a branch filter you usually get a drop-down list of branches. But you can also manually type in any other filter, which is what I do. enter image description here