DevOps管道如何修复此“允许脚本访问OAuth令牌”

时间:2020-07-16 17:23:14

标签: azure-devops

我有一个Azure DevOps管道,我想标记Azure Git存储库

task: AssembyInfoReader@2
 displayName: Set Version numbers
 inputs:
   searchPattern: 'JLReyLibrary/Properties/GlobalAssemblyInfo.cs'

获取程序集信息变量。

然后此任务导致错误:

task: GitTag@2
 displayName: Tag Repo to $(AssemblyInfo.AssemblyInformationVersion)
 inputs:
   tag: '$(AssemblyInfo.AssemblyInformationalVersion)'
   forceTagCreation: true
##[error]OAuth token not found. Make sure to have 'Allow Scripts to Access OAuth Token' enabled in the build definition.

如何设置OAuth令牌?

澄清

我尝试了以下建议。

现在我有以下问题。

  • 如何获取OAuth令牌?
  • 如何在env: Systems_AccessToken: $(System.AccessToken)中获取它

我找到了“ DevOps->组织设置-> OAuth配置”

  • 在哪里可以找到设置中字段的描述?

我仍然收到以下错误消息:

Allow Scripts to Access OAuth Token

1 个答案:

答案 0 :(得分:0)

您需要将此添加到任务中

env:
  System_AccessToken: $(System.AccessToken)

所以,在您的情况下:

- task: GitTag@2
  displayName: Tag Repo to $(AssemblyInfo.AssemblyInformationVersion)
  inputs:
    tag: '$(AssemblyInfo.AssemblyInformationalVersion)'
    forceTagCreation: true
  env:
     System_AccessToken: $(System.AccessToken)