简体   繁体   English

自动向 Azure DevOps 自托管代理添加功能

[英]automate adding capabilities to Azure DevOps self-hosted agents

As far as I know, Azure DevOps agents are capable of automatically detecting its own capabilities.据我所知,Azure DevOps 代理能够自动检测自己的能力。 Based on the documentation, so as long as I restart the host once a new piece of software has been installed, the capability should be registered automatically.根据文档,只要我在安装新软件后重新启动主机,就应该自动注册该功能。

What I am having trouble doing right now is getting the agent to detect the presence of Yarn on a self-hosted agent on a windows host.我现在遇到的问题是让代理检测 Windows 主机上自托管代理上 Yarn 的存在。 Looking at the PATH environment variable shows the existence of the Yarn executable, but it is not listed as a capability despite having the host restarted.查看 PATH 环境变量显示存在 Yarn 可执行文件,但尽管已重新启动主机,但它并未列为功能。 My current workaround is to manually add Yarn to the capability list and setting its value to true .我当前的解决方法是手动将 Yarn 添加到功能列表并将其值设置为true

As a side note, yarn was installed via Ansible using win_chocolatey plugin.作为旁注,yarn 是使用 win_chocolatey 插件通过 Ansible 安装的。 The install was successful with no errors.安装成功,没有错误。

I am wondering a few things我想知道一些事情

1) Am I missing something which is causing this issue? 1)我是否遗漏了导致此问题的某些内容?

2) Is this an inherent issue with Yarn? 2) 这是 Yarn 的固有问题吗? If this is an inherent issue with Yarn, is there a way to automate the process of manually adding yarn as a capability?如果这是 Yarn 的固有问题,有没有办法使手动添加 Yarn 的过程自动化?

Capabilities for a windows agent come from the environmental variables. Windows 代理的功能来自环境变量。

if you want to set a value you add a line that adds that adds an entry to the machine.如果你想设置一个值,你可以添加一行来添加一个条目到机器。

[System.Environment]::SetEnvironmentVariable("CAPABILITYNAME", "value", "Machine")

when you start the service it then picks this up.当您启动服务时,它会选择它。

I am currently trying to do something similar for a set of linux agents...我目前正在尝试为一组 linux 代理做类似的事情......

The interesting thing about capabilities is that they are not paths.功能的有趣之处在于它们不是路径。 for example it might show you have msbuild for 2019 and 2017, but I have not been able to use those as pipeline variables.例如,它可能会显示您有 2019 年和 2017 年的 msbuild,但我无法将它们用作管道变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM