Azure DevOps中的条件生成解决方案 [英] Conditional build solution in Azure DevOps

查看:106
本文介绍了Azure DevOps中的条件生成解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用多个小型项目/解决方案的大型应用程序.每个解决方案都内置在各自的代理中.类似于下面的截图

I am working on a large scale application which uses multiple small-small project/solutions. Each solution is built in their respective agents. Similar to below screenshot

现在的问题是,即使更改了一个项目文件,所有项目/解决方案也都已编译.

Now the problem is that all the projects/solutions are compiled even if a single project file is changed.

为了减少CI的构建时间,我想在构建中添加条件表达式,该条件表达式仅在更改其各自的源时才构建项目.

To reduce CI build time, I want to add conditional expression in the build which would build the project only if their respective source is changed.

我知道可以通过Custom condition using variable expressions在Azure DevOps中实现.但是我不确定如何检查相应的源代码

I know this can be achieved in Azure DevOps via Custom condition using variable expressions. But I am not sure how can I check if the respective source code is changed

有人知道我需要在这里写什么吗?

Does anyone know what variable expression I need to write here?

推荐答案

好吧,据我所知,您正在使用Git Repo,您​​可以按照以下方式进行操作

Well as I see your are using the Git Repo, you can do this in the below way

首先,您需要确定是否修改了哪个项目/解决方案.

As a very first step you need to find whether which project/solution is modified.

您可以从我的

You can find the solution from my answer here,where you can see I've used a simple powershell script to pull out the modified files, and enables the corresponding variables.

示例Powershell脚本以提取修改后的文件

$files=$(git diff HEAD HEAD~ --name-only)
$temp=$files -split ' '
$count=$temp.Length
echo "Total changed $count files"
For ($i=0; $i -lt $temp.Length; $i++)
{
  $name=$temp[$i]
  echo "this is $name file"
  if ($name -like "SubFolderA/*")
    {
      Write-Host "##vso[task.setvariable variable=MicroserviceAUpdated]True"
    }
}

这篇关于Azure DevOps中的条件生成解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆