在舞台上添加条件以检查文件夹上的更改

在舞台上添加条件以检查文件夹上的更改

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

问题描述

我在同一分支中同时拥有服务器端(使用c#的Web api)和客户端(角度)代码.我已经为服务器端代码和客户端代码创建了单独的阶段,并为部署又创建了一个阶段.如果我在客户端或服务器端检入代码,则这三个阶段都将运行.为避免这种情况,我正在寻找在阶段级别添加条件的方法,以便如果发生服务器端更改,则仅服务器阶段将运行,如果签入的代码仅具有客户端代码,则仅客户机阶段将运行.我不明白如何检查已签入的文件.我在搜索时发现了类似的问题,但解决方案是使用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:

谢谢.

推荐答案

我正在发布对我有用的解决方案.我分为服务器,客户端和部署三个阶段.我已经在同一分支上的两个管道中分离了阶段.现在,我在一个阶段中有Server and Deploy阶段,在另一个管道中有Client and Deploy阶段.另外,我在服务器端(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.

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

08-12 02:36