azure-devops - Azure 构建管道 - 在模板中使用“DownloadSecureFile”任务
问题描述
我有一个 Azure DevOps 项目,其中包含几个 YAML 构建管道,它们为某些任务共享一个通用模板。
我现在想DownloadSecureFile
向该模板添加一个任务,但我找不到让它工作的方法。以下代码段在添加到模板时会导致错误,但在父管道定义中可以正常工作(假设我还将${{ xx }}
变量名称的语法替换为$(xx)
版本):
- task: DownloadSecureFile@1
name: securezip
displayName: Download latest files
inputs:
secureFile: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
retryCount: 5
- task: ExtractFiles@1
displayName: Extract files
inputs:
archiveFilePatterns: ${{ variables.securezip.secureFilePath }}
destinationFolder: '${{ parameters.sourcesDir }}\secure\'
cleanDestinationFolder: true
错误发生在“提取文件”步骤并且是Input required: archiveFilePatterns
,所以看起来它只是没有找到变量。
作为一种解决方法,我可以将下载任务移动到父管道脚本并将文件路径作为参数传递。但是,这意味着复制任务,这似乎有点像 hack。
解决方案
美元双花括号中的变量在模板扩展时解析。它们不是任务的输出。
任务的输出变量由美元单括号引用,它们不需要以“变量”一词开头。
所以我相信你要找的线是这样的,它不受模板机制的影响。
archiveFilePatterns: $(securezip.secureFilePath)
推荐阅读
- list - Dart 中的 PHP array_diff() 等价物?(比较两张图,返回一张差异图)
- javascript - 使用谷歌图表创建表格图表
- r - R 字符和日期类型比较
- reactjs - 获取 TypeError:在简单的 React 教程中将“this.state”更改为“this.props.users”时 this.props.users 未定义
- python - 使用频道 ID 在 Telethon 中抓取电报消息
- android - 为什么我应该使用@Inject 注解?(安卓)
- android - 安卓位置管理器不工作。我无法获取当前位置
- sqlmap - 缺少数据库参数。sqlmap 将使用当前数据库
- javascript - 当直接访问元素而不是记录 HTMLCollection 时,元素的 clientWidth 会有所不同
- spring - 如何在应用程序运行时应用在 application.properties 文件中所做的更改?