如何允许脚本从 yaml 构建访问 OAuth 令牌

编程入门 行业动态 更新时间:2024-10-18 00:21:52
本文介绍了如何允许脚本从 yaml 构建访问 OAuth 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构建脚本使用了 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:关键词]

本文发布于:2023-03-31 09:44:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/801861.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   脚本   yaml   OAuth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!