[英]Azure - custom condition in YAML based pipeline
I've an yaml based azure CI/CT pipeline.我有一个基于 yaml 的 azure CI/CT 管道。 I've a task defined as below:
我的任务定义如下:
- task: PublishTestResults@2
displayName: 'Publish PCOM Test Results'
condition: always()
inputs:
testResultsFormat: NUnit
testResultsFiles: '*.xml'
searchFolder: '$(Common.TestResultsDirectory)/$(Build.SourceBranchName)/$(Build.BuildNumber)/test-results/PCOM'
mergeTestResults: true
testRunTitle: 'PCOM Tests'
It looks for all '*.xml' files under a particular s3 location.它查找特定 s3 位置下的所有“*.xml”文件。 But the
xml
files will be created only if the below task is successful:但是只有在以下任务成功时才会创建
xml
文件:
- bash: 'perl run_aws_cli.pl $(Build.BuildNumber) $(Build.SourceBranchName) $(s3Bucket) $(Build.SourcesDirectory)'
workingDirectory: 'azure-pipeline/scripts'
displayName: 'Run ECS Tasks'
So I want a custom condition to check if the later task is successful then only search xml
files in the directory else don't search for it.所以我想要一个自定义条件来检查后面的任务是否成功,然后只搜索目录中的
xml
文件,否则不要搜索它。 Currently it's searching always and the earlier task( Publish PCOM Test Results ) is failing.目前它一直在搜索,早期的任务(发布 PCOM 测试结果)失败了。
just do condition: succeeded()
on your second task.就在你的第二个任务上做
condition: succeeded()
。 this will only run if all the tasks before that run successfully.这只会在之前的所有任务成功运行时运行。 if you want a more sophisticated option, check this thread.
如果您想要更复杂的选项,请查看此线程。
Alternatively, you can probably get more information on the build status from the API.或者,您可以从 API 获取有关构建状态的更多信息。
https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/get?view=azure-devops-rest-5.1 https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/get?view=azure-devops-rest-5.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.