在舞台上添加条件以检查文件夹的变化 [英] Add condition on stage to check the changes on folder

查看:18
本文介绍了在舞台上添加条件以检查文件夹的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个分支中有服务器端(使用 c# 的 web api)和客户端(angular)代码.我已经为服务器端和客户端代码创建了单独的阶段来构建,还有一个阶段来部署.如果我在客户端或服务器端签入代码,则所有 3 个阶段都会运行.为了避免这种情况,我正在寻找在阶段级别添加条件的方法,以便如果有服务器端更改,则只有服务器阶段将运行,如果签入的代码只有客户端代码,则只有客户端阶段将运行.我不明白如何检查签入了哪些文件.我在搜索时发现了类似的问题,但解决方案是使用 git 给出的.我在 azure-repos 中有我的代码.有什么方法可以让我根据文件夹检查是否有更改,并在阶段中的条件下进一步使用它.像这样:

I have both server side (web api using c#) and client side (angular) code in same branch. I have created separate stage for both server side and client side code to build, and one more stage to deploy. If I check in code in either of client side or server side the all the 3 stages run. To avoid this I am looking for ways to add conditions at stage level so that if there are server side changes then only Server stage will run, if the checked in code has only client side code then only Client stage will run. I don't understand how I can check which files are checked in. I found similar kind of questions while searching but the solutions are given using git. I have my code in azure-repos. Is there any way so that I can check based on folder if there are changes and further use it in conditions in stage. Something like this:

stages: 
- stage: 'Server'
 condition: 

- stage: 'Client'
 condition: 

提前致谢.

推荐答案

我正在发布对我有用的解决方案.我有 3 个阶段的服务器、客户端和部署.我已经在同一分支的两个管道中分离了阶段.现在我在一个管道中有服务器和部署阶段,在另一个管道中有客户端和部署阶段.另外我在服务器端(Web Api)管道中使用了以下代码

I am posting the solution that worked for me. I have 3 stages Server, Client and Deploy. I have separated the stages in two pipelines on same branch. Now I have Server and Deploy stage in one and Client and Deploy stage in another pipeline. Additionally I have used the following code in server side(Web Api) pipeline

 paths:
  exclude:
  - folder Path for Client side /*

 stages: 

 - stage: 'Server'
  #  steps for building server side code
 - stage: 'Deploy'
  #  steps for Deploying server side code

以及客户端管道中的以下代码

and the following code in client side pipeline

  paths:
   include:
   - folder Path for Client side/*   

stages: 

   - stage: 'Client'
   #  steps for building client side code
   - stage: 'Deploy'
   #  steps for Deploying client side code

现在它会触发相应的管道并部署相应的构建.

Now it triggers respective pipeline and deploys respective builds.

这篇关于在舞台上添加条件以检查文件夹的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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