4

I'm trying to checkout a different repository in my pipeline.

These would be the full URLs, so both repositories live in the same Azure DevOps:

https://dev.azure.com/company/Services/_git/mylocal

https://dev.azure.com/company/OtherServices/_git/another

I am trying to execute this in my YAML located in Services/mylocal@develop :

steps:
- checkout: self
- checkout: git://OtherServices/another@develop

From what I understand this should be simple. I have full access to both repos. Nonetheless I am getting:

remote: TF401019: The Git repository with name or identifier another does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/company/OtherServices/_git/another' not found

I am not sure if this is even supported in Azure Pipelines. But if it is, then what am I doing wrong? Our DevOps guy says to try with a PAT, but how do you use a PAT in the checkout? I haven't found literature on this regard.

What other options do I have?

Thanks!

Jalex23
  • 159
  • 1
  • 7

2 Answers2

7

I have reproduced your error message: enter image description here

Here is the solution:

In Project Services:

Go to Project Settings -> Pipelines/Settings -> General/"Limit job authorization scope to current project for non-release pipelines" or "Limit job authorization scope to current project for release pipelines".

Disable one of them according to the type of your pipeline.

If the ToggleButton is grey, please disable the organization-scoped options first:

Go to Organization settings -> Pipelines/Settings ->Disable General/"Limit job authorization scope to current project for non-release pipelines" or "Limit job authorization scope to current project for release pipelines".

After the above work is completed, you can run your pipeline again. Make sure the project, repository and branch names in the checkout are correct.

Update:

Thanks @Bill Jetzer in the comments! If you are using classic UI pipeline, in addition to the above setting, please go to the edit page of your pipeline. Select "Options" tab. In "Build job" -> "Build job authorization scope", please confirm you are selecting "Project collection".

enter image description here

Jane Ma-MSFT
  • 4,461
  • 1
  • 6
  • 12
  • This worked. I set both to "off" in Project Settings and now it works. Thanks a lot!! – Jalex23 Aug 27 '20 at 19:38
  • Thanks for the link. I was wondering where to click! – Jalex23 Aug 28 '20 at 21:27
  • Thanks worked for me as well. Please refer this below link with UI http://chamindac.blogspot.com/2020/12/resolving-tf401019-git-repository-with.html – Techiemanu Nov 24 '21 at 09:34
  • Worked for me as well.. Thanks – meenu Nov 24 '21 at 09:46
  • 1
    do not work for me, i use azure repo as submodule – Maadiah Aug 11 '22 at 00:57
  • 1
    Aside from the "Limit job" settings at both the Organization and Project level, you must also configured the build pipeline "Options" tab to set the "Build job authorization scope" to "Project Collection" rather than "Current Project" – Bill Jetzer Nov 16 '22 at 16:27
  • @BillJetzer Thank you for reminding!! Your comment is very useful, and I will update it in the main answer so that more people may benefit from it. I will remove it if you don't want it. – Jane Ma-MSFT Dec 14 '22 at 08:34
1

I'm spamming my findings here because I spent far too long troubleshooting the same issue as documented here.

Ensure "Limit job authorization scope to current project for non-release pipelines" or "Limit job authorization scope to current project for release pipelines" is configured in both the source project (e.g. the pipeline that's being executed) and the remote project (e.g. where you're consuming a template form).