问题描述
我的构建脚本使用了 SYSTEM_ACCESSTOKEN
环境变量.
My build script uses the SYSTEM_ACCESSTOKEN
environment variable.
在设计器构建定义中,我选中了允许脚本访问 OAuth 令牌,一切正常.
In the designer build definition I checked Allow scripts to access the OAuth token and everything works.
复制设计器生成的 YAML 定义后,我无法访问 SYSTEM_ACCESSTOKEN
环境变量.
After copying the designer generated YAML definition I cannot access the SYSTEM_ACCESSTOKEN
environment variable.
如何允许我的 YAML 构建访问 OAuth 令牌?
How do I allow my YAML build to access the OAuth Token?
这是我的 azure-pipelines.yaml:
This is my azure-pipelines.yaml:
queue:
name: Hosted VS2017
steps:
- checkout: self
lfs: true
persistCredentials: true
- powershell: ./build.ps1
推荐答案
我在 管道变量文档:变量必须在 YAML 中声明.
I found the solution in the Pipeline Variable docs: The variable must be declared in YAML.
在所有作业/任务的管道级别:
At pipeline level for all jobs / tasks:
variables:
system_accesstoken: $(System.AccessToken)
jobs:
job: ...
或者在脚本/任务级别,例如 PowerShell:
Or at script / task level for example PowerShell:
- powershell: ./build.ps1
env:
system_accesstoken: $(System.AccessToken)
这篇关于如何允许脚本从 yaml 构建访问 OAuth 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论