skip to Main Content

I am converting a Classic Azure build pipeline into a YAML pipeline and I have this step defined:

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)

This fails with the following error:

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

I have tried:

  • With and without the checkout step
  • With and without sudo npm
  • Switching builduser for user
  • Passing the System.AccessToken in from the parent YAML file as a parameter
  • Ensured Limit job authorization scope to current project for non-release pipelines is OFF
  • Ensured Limit job authorization scope to current project for release pipelines is OFF
  • Ensured Protect access to repositories in YAML pipelines is OFF

And variations of these.

The script step in question does, of course, work in the Classic pipeline, but not in the YAML pipeline and I can’t help but think I am missing some detail of running scripts or accessing environment variables specific to YAML.

Is there anything else I might need to do?

2

Answers


  1. 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.

    As you could run your pipeline in the classic pipeline, you may check the Build job authorization scope in your classic pipeline.

    enter image description here

    If it is Current project, you may enable Limit job authorization scope to current project for non-release pipelines

    And check the Service Account: {Project Name} Build Service ({Org Name}) has the Read Permission in your target repo(Util): Project Settings -> Repositories -> Target repos(Util) -> Security.
    enter image description here

    If Build job authorization scope is Project Collection.
    enter image description here
    You may disable the Limit job authorization scope to current project for non-release pipelines for your project ourrepos.visualstudio.com/Projects/

    and check the Service Account: Project Collection Build Service (OrganizationName) has the Read Permission in your target repo(Util):
    Project Settings -> Repositories -> Target repos(Util) -> Security.

    permission

    Login or Signup to reply.
  2. Since Util repo is in the same organization but in different project, as per the error message, please follow below items for a check. I tested your yaml and it’s working on my side:

    1. You can get the correct git url when you clone repository:

    enter image description here

    The npm install command should be like below:

    npm install --no-fund -g git+https://builduser:$(System.AccessToken)@{orgname}.visualstudio.com/{projectname}/_git/{reponame}

    1. on your project which have your YAML pipeline, make sure:

    Limit job authorization scope to current project for non-release pipelines is OFF.

    Protect access to repositories in YAML pipelines is OFF.

    1. on SOURCE repository, Make sure Project Collection Build Service Accounts has read permission.

    enter image description here

    My pipeline result:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search