如何在VSTS中的托管代理上运行或安装工具 [英] How to run or install tool on hosted agent in VSTS

查看:99
本文介绍了如何在VSTS中的托管代理上运行或安装工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VSTS上以管理员身份运行cmd.

I want to run cmd as an administrator on VSTS.

实际上,我正在尝试在VSTS托管代理上使用Chocolatey Tool Manager安装git-tfs,因此我在VSTS命令行任务上运行以下命令:

Actaully I am trying to install git-tfs with chocolatey tool manager on VSTS hosted agent, So I am running the following command on VSTS command line task:

@%SystemRoot%\ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command"iex(((New-Object System.Net.WebClient).DownloadString(' https://chocolatey.org/install.ps1 '))&&设置"PATH =%PATH%;%ALLUSERSPROFILE%\ chocolatey \ bin"

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

或者,VSTS还提供了巧克力般的安装任务,您可以在屏幕截图中看到它:

Alternatively VSTS also provides the chocolatey task for installation, you can see this in the screenshot :

以上两种方法都给出相同的错误:

Both of the above approaches giving the same error:

推荐答案

我刚刚进行了以下快速测试:

I have just done a quick test which was the following:

  1. 使用Hosted 2017 Build Agent设置VSTS Build
  2. 添加了具有以下内容的PowerShell任务

  1. Set up a VSTS Build using Hosted 2017 Build Agent
  2. Added PowerShell Task with the following contents

choco列表-仅限本地

choco list --local-only

运行构建

此命令正确输出当前通过Chocolatey安装的Chocolatey软件包的列表.

This command correctly output the list of Chocolatey Packages that are currently installed via Chocolatey.

这告诉我Chocolatey已安装在Hosted 2017 Build Agent上,因此,您无需再次安装它.相反,您应该能够使用它来安装其他应用程序.

This tells me that Chocolatey is already installed on the Hosted 2017 Build Agent, and as a result, you shouldn't need to install it again. Instead, you should be able to install additional applications using it.

注意:尽管您尝试安装的软件包仍将具有相同的权限.因此,如果您尝试安装需要管理权限的应用程序,则可能会遇到相同的问题.

NOTE: The packages that you try to install will still be subject to the same permissions though. So if you are trying to install an application that requires administrative permissions, then you will likely run into the same problems.

这篇关于如何在VSTS中的托管代理上运行或安装工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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