Azure DevOps 错误名称或标识符的存储库不存在或您没有权限

问题描述 投票:0回答:1

我正在将经典 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
  • 从父 YAML 文件中传递
    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 的环境变量的一些细节。

还有什么我需要做的吗?

git azure-devops npm-install
1个回答
0
投票

远程:TF401019:具有名称或标识符 Util 的 Git 存储库 不存在或者您没有执行您正在执行的操作的权限 尝试。

您可以检查服务帐户:Project Collection Build Service (OrganizationName) 在您的目标存储库中是否具有读取权限: 项目设置 -> 存储库 -> 目标存储库 -> 安全性。

© www.soinside.com 2019 - 2024. All rights reserved.