是否可以在 Azure Repos Git 中动态设置源?
Is it possible to set source dynamically in Azure Repos Git?
我正在寻找一个解决方案来动态 select 在 Azure 管道中构建一个分支。我有 Azure Repos Git,其中 select 项目、存储库和默认分支。我希望能够 select 基于变量的分支。
我现在正在尝试的是使用 Command Line
任务并触发 git checkout
命令(例如分支是一个变量):
git checkout $(branch)
我还不能确认它能正常工作,但仍然我确认它能正常工作,但我觉得有比检查默认分支然后用命令切换分支更好的选择行。
更新:
如果你想有一个单一的管道可以为不同的分支建立不同的分支(版本分支),你可以在分支过滤器的触发器中指定它们。这不会构建所有分支。
您在构建定义中 select 的分支只是您手动排队新建构建时使用的默认分支。 OTOH 构建触发器建立要下载的分支,例如如果构建是由分支 develop 上的 git 推送触发的,那么这就是检出和构建的那个。看看这个 link:
此外,您可以禁用默认获取源代码 step.Then 使用您自己的 powershell 脚本和 git 命令手动获取源代码(正是您想要的)并检查分支,最后基于构建在你的变量上。
对于 YAML,要禁用默认 "Get Sources" 只需在中指定 none
结帐:
checkout: none
对于UI,请参考我在这个问题中的回复:
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:
如果你想动态select default branch如下,这个暂时不可用
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.您可以投票并跟踪过程。
我正在寻找一个解决方案来动态 select 在 Azure 管道中构建一个分支。我有 Azure Repos Git,其中 select 项目、存储库和默认分支。我希望能够 select 基于变量的分支。
我现在正在尝试的是使用 Command Line
任务并触发 git checkout
命令(例如分支是一个变量):
git checkout $(branch)
我还不能确认它能正常工作,但仍然我确认它能正常工作,但我觉得有比检查默认分支然后用命令切换分支更好的选择行。
更新:
如果你想有一个单一的管道可以为不同的分支建立不同的分支(版本分支),你可以在分支过滤器的触发器中指定它们。这不会构建所有分支。
您在构建定义中 select 的分支只是您手动排队新建构建时使用的默认分支。 OTOH 构建触发器建立要下载的分支,例如如果构建是由分支 develop 上的 git 推送触发的,那么这就是检出和构建的那个。看看这个 link:
此外,您可以禁用默认获取源代码 step.Then 使用您自己的 powershell 脚本和 git 命令手动获取源代码(正是您想要的)并检查分支,最后基于构建在你的变量上。
对于 YAML,要禁用默认 "Get Sources" 只需在中指定 none 结帐:
checkout: none
对于UI,请参考我在这个问题中的回复:
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:
如果你想动态select default branch如下,这个暂时不可用
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.您可以投票并跟踪过程。