git - 如何通过将标签推送到 github 来触发 Azure 管道中的构建

标签 git github azure-pipelines git-tag

当以以下方式将新标签推送到我的 github 存储库时,我试图在 Azure 管道中触发构建(dev 是标签的名称):

git tag dev
git push --tags

构建不应由任何推送特定提交到 repo 触发,只有在推送标签时才会触发。

我尝试了 azure-pipelines.yml 文件的触发器部分的各种配置,但没有成功:
trigger:
  - master
  - refs/tags/dev
trigger:
  branches:
    include:
    - master
    - refs/tags/dev
trigger:
  branches:
    include:
    - master
  tags:
    include:
    - dev

我也试过用通配符替换“dev”,但也没有。根据 docs 这应该是可能的但我似乎无法让它发挥作用。

在此先感谢您的任何帮助或建议

这是我完整的 azure-pipelines.yml 以防万一:
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
  branches:
    include:
    - master
  tags:
    include:
    - dev
pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish $(buildConfiguration)'
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

- task: PublishBuildArtifacts@1

最佳答案

对于遇到此问题的任何人,VS developercommunity 论坛上有一个主题:

https://developercommunity.visualstudio.com/content/problem/656727/build-pipeline-trigger-from-git-tag-is-not-working.html?childToView=661889#comment-661889

TLDR;是那个MS在追它。在 2019 年 7 月 19 日星期五之后的某个时间似乎出现了问题……该方法一直有效,包括那个星期五。

当我在这里时,在我进行这项工作时遇到的一个问题是我需要明确排除 '*'pr:部分除了我的触发器/标签配置...否则当我只希望它由标签推送触发时,PR 也会触发我的管道。

关于git - 如何通过将标签推送到 github 来触发 Azure 管道中的构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57185832/

相关文章:

Azure 组变量未选择我的 appsetting.json 文件变量

git - 有没有工具可以在 Ubuntu 上监视远程 Git 存储库并在提交时 pop 通知?

git status 返回 fatal : Not a git repository but . git 存在并且 HEAD 具有适当的权限

java - Maven 项目中的哪些文件应该提交给 git?

azure - 如何抑制警告 "ZipDeploy Validation WARNING: It is recommended to set app setting WEBSITE_RUN_FROM_PACKAGE = 1"

reactjs - 无法使用 Azure Pipeline 在应用服务上部署 Nextjs 应用程序

Git - 如何反转 "git reset --hard origin/master"

github - 有没有办法在 Jenkins 构建完成时得到通知?

git - 我需要 pop 并删除我的 master 分支中的 "middle"提交。我该怎么做?

git clone - 致命的 : remote error: access denied or repository not exported