简体   繁体   English

Azure Devops 依次运行两个版本

[英]Azure Devops Running Two Builds Sequentially

We have Azure Devops setup.我们有 Azure DevOps 设置。 Right now our Project will Build Twice.现在我们的项目将构建两次。

Once during Pull Request Checkin in the YAML file, and another due to Build Settings (picture below).一次是在 YAML 文件中的 Pull Request Checkin 期间,另一次是由于构建设置(下图)。

This triggers two builds, and causes our build time to double.这会触发两次构建,并导致我们的构建时间加倍。 Our Devops team mentioned this is regular practice.我们的 DevOps 团队提到这是常规做法。 Why doesn't Azure Devops just trigger one build, and or is it safer practice with two builds?为什么 Azure Devops 不只触发一个构建,或者两个构建的实践更安全?

在此处输入图片说明

Functionally the two build may not always be the same.从功能上讲,这两个版本可能并不总是相同的。

Lets say you have the below example.假设您有以下示例。 Capital letters are commits and lower-case letters are potential commits.大写字母是提交,小写字母是潜在的提交。

  e e'
 /   \
|  |   D
C  |   B 
 \ |  /
   A

This shows, two branches coming off of the A commit (master branch).这表明,两个分支来自 A 提交(主分支)。 Each feature branch had a PR created for each one.每个功能分支都有一个为每个分支创建的 PR。 One branch has a build on the e commit and the other branch had a build on the e' commit.一个分支在 e 提交上构建,另一个分支在 e' 提交上构建。 Azure devops cannot be sure which PR will be merged first. Azure DevOps 无法确定首先合并哪个 PR。

Once you merge both of the PR's you will end up with a new commit in master that has not been previously built.一旦你合并了两个 PR,你最终会在 master 中得到一个以前没有构建过的新提交。 This is described here这是描述here

   F
   E \
 / |   D
C  |   B 
 \ |  /
   A

If you want to eliminate the need for your build on master, you can set the build expiration to Immediately when branch name is updated如果您想消除在 master 上构建的需要,您可以将构建过期时间设置为Immediately when branch name is updated

Why doesn't Azure Devops just trigger one build, and or is it safer practice with two builds?为什么 Azure Devops 不只触发一个构建,或者两个构建的实践更安全?

As far as I know, this is the expected workflow of Azure Devops.据我所知,这是 Azure Devops 的预期工作流程。

due to Build Settings由于构建设置

This is the Pull Request trigger .这是拉取请求触发器

This trigger occurs in the process of Pull Request, the PR trigger is meant to run whenever a PR is created.此触发器发生在 Pull Request 的过程中,PR 触发器旨在在创建 PR 时运行。

This trigger is equivalent to a verification step, the file is not really committed to the target branch(Pre-merged to Targer Branch).这个触发器相当于一个验证步骤,文件并没有真正提交到目标分支(Pre-merged to Targer Branch)。

You can check the results of the build to determine whether the source branch code is valid.您可以检查构建结果以确定源分支代码是否有效。

For example:例如:

If the Pull Request trigger fails, you can reject the pull request.如果拉取请求触发器失败,您可以拒绝拉取请求。 It does not affect the target branch, the target branch remains in the original state不影响目标分支,目标分支保持原状

Pull Request Checkin in the YAML file在 YAML 文件中拉取请求签入

This could be the CI trigger .这可能是CI 触发器

This trigger will happen when the pull request is completed.这个触发器会在拉取请求完成时发生。

In this case, the target branch has changed.在这种情况下,目标分支已更改。 The change of the target branch triggers the CI trigger.目标分支的变化触发 CI 触发器。 This can double check whether the code is valid.这可以再次检查代码是否有效。

Summary of workflow:工作流程总结:

Create Pull Request -> Pull Request Trigger(Pre-merged and firest check)->Complete Pull Request -> CI trigger (Complete the branch merge and second check).创建 Pull Request -> Pull Request Trigger(Pre-merged and firest check)->Complete Pull Request -> CI trigger(完成分支合并和第二次检查)。

By the way, if you want to exclude some files so that they do not trigger the Pull Request Trigger, you can add a path filter.顺便说一句,如果你想排除一些文件,这样它们就不会触发 Pull Request Trigger,你可以添加一个路径过滤器。

For example:例如:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM