【发布时间】:2020-04-25 05:05:06
【问题描述】:
好的,所以我们正在研究微服务架构,并尝试在 azure devOps 上部署代码。我们实际上只想在一个项目发生变化时触发一个管道。我们正在使用 monorepo 架构。
这就是我当前为项目特定的 build.yaml 添加条件的方式
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
steps:
# for PowerShell Core
- pwsh: ./build.ps1
# Restore sms-messaging micro service projects
- task: DotNetCoreCLI@1
displayName: Run dotnet restore
inputs:
command: "restore"
projects: sms-messaging/src/**/*.csproj
condition: and(succeeded(), eq(variables['SmsMessaging'], 'True'))
condition 包含之前执行的 powershell 脚本中的变量 SmsMessaging。
$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 "sms-messaging/*")
{
echo "changes in sms-messaging"
Write-Host "##vso[task.setvariable variable=SmsMessaging]True"
}
}
所以实际的问题是,在推送到 repo 时。所有管道触发。由于添加的条件,任务确实会被跳过。但我们实际上并不想触发所有管道。
为此,我创建了一个包含 powerShell 脚本和变量的主管道。并将有条件地触发其他管道。
但我无法向此 yaml 添加“条件”。
resources:
pipelines:
- pipeline: SmsMessaging
project: SmsMessaging
source: SmsMessaging
trigger:
branches:
include:
- master
(i want to add condition here maybe if thats possible ? and trigger different pipelines from here. Or if there is another approach)
这是正确的方法吗?任何帮助表示赞赏。谢谢
编辑:我还尝试通过 Powershell 登录并触发管道。
Invoke-AzDataFactoryV2Pipeline -ResourceGroupName "RGName" -DataFactoryName "FactoryName" -PipelineName "PipelineName"
但它不允许我运行管道说需要组织 ID。
【问题讨论】:
标签: azure azure-devops microservices