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

Wel*_*ist 6 c++ continuous-integration yaml g++ azure-devops

操作:我尝试在自托管 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
Run Code Online (Sandbox Code Playgroud)

信息与测试:

  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'
Run Code Online (Sandbox Code Playgroud)

(更新) 解决方案:

谢谢,按照下面的答案中所述更新它并阅读更多的池 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'

Run Code Online (Sandbox Code Playgroud)

Kev*_*SFT 6

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

pool:
  name: Default
  demands:
   - agent.name -equals Weltgeist  
Run Code Online (Sandbox Code Playgroud)

然后它应该按预期工作。

您可以参考Yaml 中有关 POOL Definition的文档。


小智 6

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

扩展此处提供的答案。

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

Run Code Online (Sandbox Code Playgroud)

您可以在此处找到 DevOps 中的信息。

在此输入图像描述