0

I'm having issue with running a piece of PS code within a task within my pipeline. Provided below is the code:

cd C:\PowerShell
# Change directory to location where TF.exe is hosted on the server.
Set-Alias tf "C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"
#.\TF.exe vc workspace /new temp /noprompt /collection:https://dev.azure.com/organization/ProjectName/ /login:$userName,$password
#tf workfold 
# Create the branch and check it in.
#.\TF.exe vc workspace /collection:https://dev.azure.com/organization/ProjectName/ /noprompt
tf vc branch  $/HunterWidgets/BCWidgets "C:\AzureDevOps\HunterWidgets\$($newBranchName)" /checkin /login:$userName, $password

I'm attempting to create a brand new branch. Everything works fine when I run this inside of my console on my server, but when I run it within my pipeline task it get the following error:

##[error]tf : Unable to determine the workspace. You may be able to correct this by running 'tf workspaces

##[error]/collection:TeamProjectCollectionUrl'.

I'm not sure what is going on. Any help will be greatly appreciated.

Thank you,

Brandon Michael Hunter
  • 1,179
  • 3
  • 20
  • 48
  • the console location should be inside a folder that mapped with a workspace. – Shayki Abramczyk Jul 20 '20 at 21:06
  • That didn't work. Now it says it cannot connect to Team Foundation Server. When running this code in PowerShell on the server, it worked. – Brandon Michael Hunter Jul 21 '20 at 00:25
  • What kind of agent are you using(self-hosted or microsoft-hosted)? Agree with Shayki Abramczyk ,you need to navigate to folder in the workspace. On the other hand,if your build agent was registered with `network service`. Give a try with changing it to a windows user with enough build permission. You also could run `Tf workspace` command to determine the workspace. For `cannot connect to Team Foundation Server`, could you share some detailed message? – Kevin Lu-MSFT Jul 21 '20 at 06:55

0 Answers0