gpt4 book ai didi

azure-devops - 是否可以在 Azure Repos Git 中动态设置源?

转载 作者:行者123 更新时间:2023-12-04 04:01:33 26 4
gpt4 key购买 nike

我正在寻找一种解决方案来动态选择要在 Azure 管道中构建的分支。我有 Azure Repos Git,我在其中选择项目、存储库和默认分支。我希望能够根据变量选择分支。

我现在正在尝试的是使用 命令行 任务并触发 git checkout 命令(例如 branch 是一个变量):

git checkout $(分支)

我还不能确认它能正常工作,但仍然 我确认它能正常工作,但我觉得有比检查默认分支然后用命令行切换分支更好的选择。

最佳答案

更新:

如果你想有一个单一的管道可以为不同的分支建立不同的分支(版本分支),你可以在分支过滤器的触发器中指定它们。这不会构建所有分支。

您在构建定义中选择的分支只是您手动排队新建构建时使用的默认分支。 OTOH 构建触发器建立要下载的分支,例如如果构建是由 git push on branch develop 触发的,那么就是 check out 和构建的那个。查看此链接:Get the sources from the branch that triggered the build in Team Services

此外,您可以禁用默认的获取源代码步骤。然后使用您自己的 powershell 脚本和 git 命令手动获取源代码(只是您想要的)并检查分支,最后基于您的变量构建。


Assuming you're choosing the default branch. That doesn't mean that it's the only branch that can be built by that build definition.

You can choose which branches to monitor for CI (on the Triggers tab, you can add multiple branch filters to represent the branches you wish to build on commit), and the appropriate branch will be checked out when the build is triggered. You can also choose an alternate branch when manually queuing the build.

Source Link: Get Sources from multiple branches

如果要动态选择 default branch 如下,这个暂时没有。

enter image description here

This is the branch that you want to be the default when you manually queue this build. If you set a scheduled trigger for the build, this is the branch from which your build will get the latest sources.

The default branch has no bearing when the build is triggered through continuous integration (CI). Usually you'll set this to be the same as the default branch of the repository (for example, "master").

这里有一个相关的用户声音:When triggering a build, use the same branch as the trigger build.您可以投赞成票并跟踪流程。

关于azure-devops - 是否可以在 Azure Repos Git 中动态设置源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58199696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com