Create a workspace from Powershell as part of the VS Team Services assembly

I am writing a Powershell script as part of a Visual Studio Team Services build, this build uses the built-in build controller. The script is designed to check the file, make changes and check it back.

In a script, I'm trying to call a command tfto create a new workspace, but I'm having authentication issues. Team

& $tf vc workspace /new $tempWorkspaceName /collection:https://mycollection.visualstudio.com/ 

causes an error:

TF30063: You do not have access to https://mycollection.visualstudio.com/ .

How can I access TFS from my Powershell script without embedding logins or passwords in the script? Can I access TFS in the context of the build agent, which itself is part of TFS? Or is there another way I have to do this?

Note that I did not use the TFS Power Tool cmdlets, as this is a hosted assembly server. Using TFS RestAPI is also not an option, since there is no way to check the file in or out.

+4
source share
1 answer
  • Check the Allow scripts to access OAuth Token options for your build box. enter image description here
  • Add / noprompt / loginType: OAuth / login:., $ (System.AccessToken) to the TF command (arguments)

About the TF team, you can check out this article.

+4
source

Source: https://habr.com/ru/post/1661522/


All Articles