0
votes

I'm starting to lose my sanity over a yaml build. This is the very first yaml build I've ever tried to configure, so it's likely I'm doing some basic mistake.

This is my yaml build definition:

name: ops-tools-delete-failed-containers-$(Date:yyyyMMdd)$(Rev:.rrrr)

trigger:
  branches:
    include:
      - master
      - features/120414-delete-failed-container-instances

schedules:
- cron: '20,50 * * * *'
  displayName: At minutes 20 and 50
  branches:
    include:
    - features/120414-delete-failed-container-instances
  always: 'true'

pool: 
  name: Standard-Windows

variables:
  - name: ResourceGroup
    value: myResourceGroup

stages:
  - stage: Delete
    displayName: Delete containers
    jobs:
      - job: Job1
        steps:
        - task: AzureCLI@2
          inputs:
            azureSubscription: 'CPA (Infrastructure) (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx)'
            scriptType: 'pscore'
            scriptLocation: 'scriptPath'
            scriptPath: 'General/Automation/ACI/Delete-FailedContainerInstances.ps1'
            arguments: '-ResourceGroup $(ResourceGroup)'

So in short, I want to run a script using an Azure CLI task. When I queue a new build it stays like this forever:

enter image description here

I've tried running the same task with an inline script without success. The same thing happens if I try to run a Powershell task instead of an Azure CLI task.

What am I missing here?

2

2 Answers

0
votes

Cannot run Azure CLI task on yaml build

Your YAML file should be correct. I have test your YAML in my side, it works fine.

The only place I modified is change the agent pool with my private agent:

pool: 
  name: MyPrivateAgent

Besides, according to the state in your image:

enter image description here

So, It seems your private agent under the agent queue which you specified for the build definition is not running:

enter image description here

Make the agent running, then the build will start.

As test, you could use the hosted agent instead of your private agent, like:

pool:
  vmImage: 'ubuntu-latest'

Hope this helps.

0
votes

TL;DR issue was caused by (lack of) permissions.

More details

After enabling the following feature I could see more details about the problem: Multi-stage pipelines feature

The following warning was shown after enabling the feature: Build warning

Clicking on View shows the Azure subscription used in the Azure CLI task. After clicking on Permit, everything works as expected.

enter image description here