通过在VS Team Services构建中运行的Powershell创建工作区 [英] Create a workspace from Powershell run within VS Team Services build

查看:78
本文介绍了通过在VS Team Services构建中运行的Powershell创建工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Powershell脚本编写为Visual Studio Team Services构建的一部分,该构建使用托管的构建控制器.该脚本旨在检出文件,进行更改然后将其检回.

I am writing a Powershell script as part of a Visual Studio Team Services build, this build uses a hosted build controller. The script is intended to check out a file, make changes then check it back in.

在脚本中,我试图调用tf命令来创建新的工作区,但是遇到身份验证问题.命令

In the script I am trying to invoke the tf command to create a new workspace but I'm having authentication issues. The command

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

产生错误:

TF30063:您无权访问 https://mycollection.visualstudio.com/.

如何在不将登录名或密码嵌入脚本的情况下从Powershell脚本访问TFS?我可以在本身登录到TFS的构建代理的上下文中访问TFS吗?还是我应该采取另一种方式?

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

请注意,我没有使用TFS Power Tool cmdlet,因为它是托管的构建服务器.似乎也没有使用TFS RestAPI的选择,因为没有工具可以签入或签出文件.

Note that I haven't used the TFS Power Tool cmdlets as it is a hosted build server. Using the TFS RestAPI also doesn't appear to be an option as there is no facility to check a file in or out.

推荐答案

  1. 选中允许脚本访问您的构建定义的OAuth令牌"选项
  2. /noprompt/loginType:OAuth/login:.,$(System.AccessToken)附加到TF命令(参数)
  1. Check Allow Scripts to Access OAuth Token option of your build defition
  2. Append /noprompt /loginType:OAuth /login:.,$(System.AccessToken) to your TF command (arguments)

关于TF命令,您可以查看文章.

About TF Command, you can check this article.

这篇关于通过在VS Team Services构建中运行的Powershell创建工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆