0

My build fails with below error. I want to get this option enabled in pipeline. Could someone help me with how can I do this? I can select this option in additional options section in release pipeline. But not sure on how to do it in build pipeline.

##[error]OAuth token not found. Make sure to have 'Allow Scripts to Access OAuth Token' enabled in the build definition.

priya
  • 391
  • 1
  • 5
  • 24

1 Answers1

0

##[error]OAuth token not found. Make sure to have 'Allow Scripts to Access OAuth Token' enabled in the build definition.

For this issue, check the option shown in the figure below in the agent job

enter image description here

For yaml pipeline, at script / task level for example PowerShell:

- powershell: ./build.ps1
  env:
      system_accesstoken: $(System.AccessToken)

Here is the ticket you can refer to.

Update:

  - task: GitCopyDiff@1
    inputs:
      destination: '$(Build.ArtifactStagingDirectory)/diff'
      changeType: 'M'
    env: 
     SYSTEM_ACCESSTOKEN: $(system.accesstoken)

enter image description here

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • I have tried below still getting same issue trigger: - master variables: system_accesstoken: $(System.AccessToken) - task: GitCopyDiff@1 inputs: destination: '$(Build.ArtifactStagingDirectory)/diff' changeType: 'M' – priya Nov 26 '20 at 09:39
  • How about [this](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#systemaccesstoken) : `env: SYSTEM_ACCESSTOKEN: $(System.AccessToken)` In addition, check `System.AccessToken` 's [scope](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/access-tokens?view=azure-devops&tabs=yaml#job-authorization-scope). – Hugh Lin Nov 26 '20 at 09:47
  • I am not able to declare the variable in the gitcopydiff task...this variable as per my understanding should be given in powershell/ bash task...so am not able to get it how can I make the task use the systemaccess token. – priya Nov 26 '20 at 10:25
  • Thanq Lin it works...could u suggest me for this question if possible? https://stackoverflow.com/q/65032549/13460189 – priya Nov 27 '20 at 08:49