Azure DevOps YAML 自托管代理管道构建停留在定位自代理

问题描述 投票:0回答:5

操作:我尝试在自托管 Windows 计算机上配置和运行简单的 c++ azure 管道。我对这一切都很陌生。我运行了下面的脚本。

预期:看到构建任务、显示任务和清理任务。看到你好词。

结果:错误,脚本找不到我的构建代理。

##[warning]An image label with the label Weltgeist does not exist.
,##[error]The remote provider was unable to process the request.
Pool: Azure Pipelines
Image: Weltgeist
Started: Today at 10:16 p.m.
Duration: 14m 23s

信息与测试:

  1. 我的自托管代理名称是 Weltgeist,它是 默认代理池。它是一台 Windows 计算机,带有所有 g++、mingw 和 其他相关工具。

  2. 我在本地尝试了构建任务,没有任何问题。

  3. 我使用azure“ubuntu-latest”代理尝试了我的构建任务,没有 问题。

  4. 我按照这些规范创建了自托管代理。 我是 azure 存储库的所有者。 https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops

如何正确配置自托管代理的池 ymal 参数? 我需要在服务器端执行额外的步骤吗?或者在 azure repo 配置上? 对于出了什么问题还有其他想法吗?


# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'Weltgeist' #Testing with self-hosted agent

steps:
- script: |
    mkdir ./build
    g++ -g ./src/hello-world.cpp -o ./build/hello-world.exe
  displayName: 'Run a build script'

- script: |
    ./build/hello-world.exe
  displayName: 'Run Display task'

- script: |
    rm -r build
  displayName: 'Clean task'

(更新) 解决方案:

Thx,按照下面的答案中所述更新它并阅读更多的池 ymal 定义后,它就可以工作了。请注意,我修改了其他几行以使其适用于我的环境。


trigger:
- master

pool:
  name: Default
  demands:
   - agent.name -equals Weltgeist

steps:
- script: |
    mkdir build
    g++ -o ./build/hello-world.exe ./src/hello-world.cpp
  displayName: 'Run a build script'

- script: |
    cd build
    hello-world.exe
    cd ..
  displayName: 'Run Display task'

- script: |
    rm -r build
  displayName: 'Clean task'

c++ azure-devops continuous-integration yaml g++
5个回答
6
投票

由于您使用的是自托管代理,因此可以使用以下格式:

pool:
  name: Default
  demands:
   - agent.name -equals Weltgeist  

然后它应该按预期工作。

您可以参考Yaml中POOL定义的文档。


6
投票

我对

Default
感到困惑,因为组织中已经有一个名为
Default
的管道。

扩展此处提供的答案。

pool:
  name: NameOfYourPool
  demands:
   - agent.name -equals NameOfYourAgent

这是您可以在 DevOps 中找到该信息的屏幕。


0
投票

我遇到了同样的问题,用“名称”替换池下的 vmImage 对我有用。全氟FB,

触发:

  • 大师

泳池: 名称:'Weltgeist' #使用自托管代理进行测试


0
投票

另请注意,如果您的代理仅出现在“Azure Pipelines”池中,而不出现在任何其他池中,则该代理可能已配置为“环境”资源,并且不能用作构建步骤。 我花了很长时间尝试使用自托管虚拟机进行构建步骤,认为引用虚拟机的正确方法是从“管道”>“环境”区域创建虚拟机资源:

代理将在“Azure Pipelines”池中正确创建并可见,但在任何其他池中不可用,这意味着无法在用于设置用于构建的服务器的 yaml 中引用它。

我能够通过使用

.\config.cmd remove
在我的自托管虚拟机上取消注册代理并运行
./config
来解决该问题,而无需使用上述注册脚本中提供的
--environment --environmentname "<name>"
(如“添加资源”截图)

奇怪的是,注册脚本是比代理池中显示的“新代理”表单更快的注册代理的方法:

必要的文件将被拉至服务器(无需先下载),并自动生成具有 3 小时生命周期的 PAT。


0
投票

就我而言,我必须将自托管构建代理更新到最新版本,从 2.217.2/2.210.1 到 3.225.2 由于构建代理的自动更新多次失败,我不得不手动执行。

我的 Azure DevOps Server 版本是 2022 Update 1

此后,构建最终由最新的一个代理处理。

© www.soinside.com 2019 - 2024. All rights reserved.