azure-devops - 条件内带有 bash 表达式的 Azure Pipeline
问题描述
如何在条件下使用 bash 脚本?
- bash: export PYTHONPATH="src/"
condition: succeeded(fileExists('./src/'))
displayName: Add src/ Path if Exists
condition: succeeded(fileExists('./src/'))
这似乎不起作用,它在下面显示以下错误消息:
##[error]Unrecognized value: 'fileExists'.
解决方案
条件不是这样,您可以在那里检查变量值,检查文档。
因此,如果要检查文件是否存在,则需要添加另一个脚本任务来检查文件是否存在,如果存在则设置一个变量,而不是在条件中使用此变量。
像这样的东西:
- bash: |
if [ -f /tmp/foo.txt ]; then
echo "##vso[task.setvariable variable=fileExist]true"
fi
- bash: export PYTHONPATH="src/"
condition: and(succeeded(), eq(variables['fileExist'], 'true'))
推荐阅读
- java - Openfeign 如何使用 @Headers 注解与不同的生产和消费类型?
- azure-aks - 使用 terraform 的节点池的 aks-engine 自定义映像
- apache-spark - SparkContext:运行 Spark 作业时初始化 SparkContext 时出错
- html - 如果输入标签中的文本已经存在于数组中,则替换它们
- powershell - 枚举 URL Scheme 表单 powershell
- ios - InAppBrowser IOS 14
- r - R循环从几个后续行子集信息并创建新列
- vue.js - 将成分添加到购物清单
- javascript - 从字符串列表创建树 - javascript
- javascript - ES6 解构并作为参数一起传播到 React 组件中