我正在将经典 Azure 构建管道转换为 YAML 管道,并且定义了此步骤:
parameters:
RestoreBuildProjects: '**/*.csproj'
buildConfiguration: 'Any CPU'
TestProjects: '**/*Tests/*.csproj'
stages:
- stage: Build
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
jobs:
- job: Build_Application
continueOnError: false
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
persistCredentials: true
- script: |
npm install --no-fund -g git+https://builduser:$(System.AccessToken)@ourrepos.visualstudio.com/Projects/_git/Util
displayName: 'npm install util'
workingDirectory: $(Build.SourcesDirectory)
此操作失败并出现以下错误:
npm ERR! command git --no-replace-objects ls-remote https://builduser:***@ourrepos.visualstudio.com/Projects/_git/Util
npm ERR! remote: TF401019: The Git repository with name or identifier Util does not exist or you do not have permissions for the operation you are attempting.
npm ERR! fatal: repository 'https://ourrepos.visualstudio.com/Projects/_git/Util/' not found
我已经尝试过:
checkout
步骤sudo npm
builduser
为 user
System.AccessToken
作为参数Limit job authorization scope to current project for non-release pipelines
关闭Limit job authorization scope to current project for release pipelines
关闭Protect access to repositories in YAML pipelines
关闭以及这些的变体。
当然,有问题的脚本步骤可以在经典管道中工作,但不能在 YAML 管道中工作,我忍不住认为我缺少运行脚本或访问特定于 YAML 的环境变量的一些细节。
还有什么我需要做的吗?