I created azure devops pipeline where I need to download code from another git repository. As per recommended solution I've read somewhere, I added a command line script task with git clone command. Unfortunatelly this doesn't work.
The error that I get is: remote: TF200016: The following project does not exist: My0Test0Project. Verify that the name of the project is correct and that the project exists on the specified Azure DevOps Server. fatal: repository 'https://dev.azure.com/myCompany/My0Test0Project/_git/Service.Azure.Core/' not found
My project in Azure has spaces, maybe there is a bug in azure related to that? Does anybody knows any workarounds?
This is some code that I have tried already:
git -c http.extraheader="AUTHORIZATION: Basic bXl1c2VyOmxtNjRpYTYzb283bW1iYXp1bnpzMml2eWxzbXZoZXE2azR1b3V2bXdzbnl5b3R5YWlnY2E=" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git clone https://oauth:lm64ia63oo7mmbazunzs2ivylsmvheq6k4uouvmwsnyyotyaigca@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git clone https://test:$(System.AccessToken)@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
Verify the location of the cloned repo on your PC and select Clone. If you aren't using Azure Repos, you can still clone your repo in Team Explorer and work with your code in Visual Studio. In Team Explorer, open the Connect view, as explained above. Select Clone under Local Git Repositories and enter the URL for your Git repo.
If you're using Azure Repos, Azure DevOps Server 2019, or Team Foundation Server, you can find this clone URL in the web portal. From your web browser, open the team project for your Azure DevOps organization and choose Repos, then Files. Select Clone in the upper right. If you need to clone a GitHub repo,...
In order to give it permission to clone you can either add your username and password or add a personal access token (PAT) to the url in the gitmodules file in your repo on Azure devops. You need to change the url to https://username:[email protected]/organization/project/_git/repo or https://[email protected]/organization/project/_git/repo
In Team Explorer, open the Connect view, as explained above. Select Clone under Local Git Repositories and enter the URL for your Git repo. Your team or Git hosting provider gives you this URL. Select a folder where you want your cloned repo. Select Clone to clone the repo.
The reason is because you need to add the system access token so that Azure can have access to the external repo. (your credentials need access to that repo)
NOTE:
I wrapped my URL in quotes to escape the % signs in the URL string because Powershell treats those as variables otherwise.
- powershell: |
git clone -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" "https://{YOUR PIPELINE URL}"
displayName: '{YOUR PIPELINE NAME}'
I had the same issue from a bash script and solved it by escaping the %
character with %%
.
So, you can use this :
git clone https://test:$(System.AccessToken)@dev.azure.com/myCompany/My%%20Test%%20Project/_git/Service.Azure.Core
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With