Search code examples
c++azure-devopscontinuous-integrationyamlg++

Azure DevOps YAML self hosted agent pipeline build is stuck at locating self-agent


Action: I tried to configure and run a simple c++ azure pipeline on a self-hosted windows computer. I'm pretty new to all this. I ran the script below.

Expected: to see build task, display task and clean task. to see hello word.

Result: Error, script can't find my build agent.

##[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

Info & Test:

  1. My self-hosted agent name is Weltgeist and it's part of the default agent pools.it's a windows computer, with all g++, mingw and other related tools on it.

  2. I tried my build task locally with no problem.

  3. I tried my build task using azure 'ubuntu-latest' agent with no problem.

  4. I created the self-hosted agent following these specification. I'm the owner of the azure repo. https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops

How do I configure correctly the pool ymal parameter for self-hosted agent ? Do i have addition steps to do server side? or on azure repo configs? Any other idea of what went wrong?


# 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'

(UPDATE) Solution:

Thx, after updating it as stated in a answer below and reading a bit more pool ymal definition it works. Note, I modified a couple of other lines to make it work on my environment.


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'


Solution

  • Since you are using the self-hosted agent, you could use the following format:

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

    Then it should work as expected.

    You could refer to the doc about POOL Definition in Yaml.