0
votes

I’m working on Azure pipelines that connects to my Windows Self-Hosted agent.
I understood I can access the projects I have stored on an intranet TFS 2018 server but I keep having “Authentication failed” errors.

Does it depend on the project type in TFS ?
I never used Git before to connect to my project in VS 2019. On the machine, under the same account, where I work on this project with VS2019, I tried those commands:

git clone https://tfs.myCie.com/DefaultCollection/myProject/

> Result:   Cloning into ' myProject '... 
> fatal: repository 'https://tfs.myCie.com/DefaultCollection/myProject/' not found

git clone https://user:<PAT>@tfs.myCie.com/DefaultCollection/myProject/

> Result:   Cloning into ' myProject '... 
> fatal: Authentication failed for 'https://user:<PAT>@tfs.myCie.com/DefaultCollection/myProject/'

I’m currently part of the groups: “Contributors” and “Project Administrators” in this TFS project.

I am wondering where the problem is, can it be a git proxy error ?
Can it be a TFS access rights error ?
Can it be a project type problem, maybe some projects in TFS can’t be accessed from Git ? Does it requires that Basic authentication is enabled on the server ?

UPDATE 1

On first attempts to create a pipeline that get the sources on a on-prem TFS instance, it wasn't working, I suspect because git, on the agent is configured to use a proxy and that proxy doesn't allow connecting to internal TFS server.

I wanted to work around that and create a pipeline that doesn't get sources but runs a script to clone the repo on the agent and then build it: enter image description here

As the script in the pipeline wasn't working, I tried it in a command prompt on my pc where VS2019 does connect to the "repo".

You probably have a point saying it doesn't look like a repo, I never worked with Git, I used to open Visual Studio, open the Team Explorer, select my project and do my check-outs, check-ins.

It is only today that I notice Team Explorer shows the name: Azure DevOps Server but I know behind is TFS 2018 server: enter image description here

I understood I can use Git to clone the "repo" from my TFS server but maybe that situation is not covered, that's why I was asking several questions... as I am not even sure what I want to do is possible, you asked what is the clone repo URI I get but I can't find a clone repo URI :(

On a more general way, I was asked to create Azure DevOps Pipelines for all of our projects, it all must run on a Windows Self-Hosted agent, we have projects on GitHub, on Azure Repos and on this on'prem TFS server. I have pipelines for the first two but I can't make this connection to TFS work.

Update 2

Thank you for your directions, it seems I don't have the same UI as you are showing, or I didn't find it but I did look for it...

Here is what I see when I open the project in TFS:

enter image description here

1
I don't understand what you're asking. Are you having a problem cloning a repo on your desktop machine? Or are you having a problem cloning the repo during a build process? What does your build pipeline look like? That url https://user:<PAT>@tfs.myCie.com/DefaultCollection/myProject/ does not look like a Git repo URI. When you go to the repo, what is the clone URI?Daniel Mann
In general, you need to provide as much information as possible. Are you trying to use a separate Azure DevOps account to clone a Git repo hosted in an on-prem TFS instance? Please explain exactly what you're attempting to accomplish.Daniel Mann
Sorry to be unclear, I’m on this since awhile now… I wanted to create a pipeline that uses a service connection to connect to the intranet TFS Server but didn’t worked out so I have skipped the sources part of the pipeline and now, I am working on a script that runs on the agent to clone the repo and built it there. I will update my question trying to make it clearer.ClaudeVernier
That's not a Git repo, that's a TFVC repo. You'll need to adapt whatever process you're attempting to implement to use TFVC.Daniel Mann
Oh! Ok, thank you for that ! I dunno why I understood I could access it with Git... I'll read about getting source code from a on-prem TFS instance of a TFVC repo.ClaudeVernier

1 Answers

-1
votes

To find the Git Clone URL, you could sign in the TFS 2018, then navigate to Project ->Code -> Files, you could get the Git Clone URL in the Clone Option

enter image description here

The Resources field of yaml pipeline does not currently support to get the repo in TFS.

So in Azure Devops Pipelines, you can use the following two methods to get the git repo in TFS.

  1. Use Git Clone Command: you could add PAT in the URL:

For example:

pool:
  name: Default

workspace:
  clean: all
steps:

- checkout: none

- task: CmdLine@2
  inputs:
    script: |
      cd $(Build.sourcesdirectory)
      
      git clone -b master http://<PAT>@tfs2018:8080/tfs/DefaultCollection/_git/<RepoName>
  1. You could create an Other Git Service Connection and use the Other Git option.This method can only be used in classic Editor.

enter image description here

Note: You need to make sure that the Windows Self-Hosted agent could visist the TFS2018. In other words, the local machine where the agent is located needs to be able to access TFS2018.

Update:

For TFVC Repo:

You could try to use the following command:

cd $(build.sourcesdirectory)
tf vc workspace /new ... 
tf vc workfold /map $/Project/Folder $(build.sourcesdirectory) 
tf vc get . /recursive