简体   繁体   English

如何避免重新部署相同的工件?

[英]How to Avoid redeployment of same artifact?

In our Client project we have 6 applications, Three Java and three .NET.在我们的客户端项目中,我们有 6 个应用程序,三个 Java 和三个 .NET。 We have the code in the same repository in different folders for each app.我们在每个应用程序的不同文件夹中的同一存储库中都有代码。 The case is that we need to compare the artifacts which is being built with the previous builds to know changes are made or not.情况是我们需要将正在构建的工件与以前的构建进行比较,以了解是否进行了更改。 If changes are made then deploy it else Do not deploy it.如果进行了更改,则部署它,否则不要部署它。 Also, based on the apps.此外,基于应用程序。 Say if I work on the One Java and one .NET app, I will want to deploy only these two and rest four apps need not be deployed unnecessarily.假设我在一个 Java 和一个 .NET 应用程序上工作,我只想部署这两个应用程序,而 rest 四个应用程序不需要部署。 How can we achieve this without manual intervention?我们如何在没有人工干预的情况下实现这一目标? Please suggest us with a solution.请向我们提出解决方案。

You can try to set up a build pipeline and corresponding release pipeline for each app.您可以尝试为每个应用程序设置构建管道和相应的发布管道。

  1. In the build pipeline for each app, you can use the ' Paths ' key to specify the file paths that can trigger the build pipeline.在每个应用程序的构建管道中,您可以使用“ 路径”键来指定可以触发构建管道的文件路径。

  2. In the release pipeline for each app, you can try setting up a step to execute the API " Builds - Get Changes Between Builds " to get the changes between the current build and previous build.在每个应用程序的发布管道中,您可以尝试设置一个步骤来执行 API “ Builds - Get Changes Between Builds ”,以获取当前构建与先前构建之间的更改。 If no any change made between the two builds, skip the subsequent deployment step.如果两个构建之间没有任何更改,请跳过后续部署步骤。

[UPDATE] [更新]

Is there any equivalent API which could provide the difference between two artifacts even if the build manually runs without any changes?是否有任何等效的 API 可以提供两个工件之间的差异,即使构建手动运行而没有任何更改? So if we do not see any changes in result we could cancel the release pipeline.因此,如果我们没有看到结果有任何变化,我们可以取消发布管道。

To avoid deploying the artifacts that have the same source version, as I mentioned above, you can try using the API " Builds - Get Changes Between Builds ".为避免部署具有相同源版本的工件,如上所述,您可以尝试使用 API“ Builds - Get Changes Between Builds ”。 In Response body of this API, it will return the array list of commits between the two specified builds.在此 API 的响应正文中,它将返回两个指定构建之间的提交数组列表。

  • If have changes between the two builds, the value of " count " property is the number of the commits.如果两个构建之间有变化,“ count ”属性的值是提交的数量。 And in the " value "property (array object), these commits will be listed.并且在“”属性(数组对象)中,这些提交将被列出。

    在此处输入图像描述

  • If no any change between the two builds, the value of " count " is 0, and " value " is an empty array.如果两次构建之间没有任何变化,“ count ”的值为0,“ value ”是一个空数组。

    在此处输入图像描述

In your case, you just need to check whether the value of " count " is greater than 0. If greater than 0, start the deployment.在您的情况下,您只需要检查“ count ”的值是否大于0。如果大于0,则开始部署。 If equal to 0, skip the deployment to avoid re-deployment.如果等于 0,则跳过部署以避免重新部署。

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

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