简体   繁体   中英

Azure pipeline CLI task with acr purge getting failed

Getting below error

ERROR: The command failed with an unexpected error. Here is the traceback: ERROR: 'NoneType' object is not callable Traceback (most recent call last): File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke

pool: 
  vmImage: ubuntu-latest

stages:
  - stage: ACR_cleanup
    jobs:
      - job: acr_cleanup
        steps:
          - task: AzureCLI@2
            displayName: Azure CLI
            inputs:
              azureSubscription: Cleanup_SC
              scriptType: bash
              scriptLocation: inlineScript
              inlineScript: |
                az --version
                az account show
                az acr run --cmd "acr purge --filter 'my-image:.*' --ago 30d --untagged" --registry <> /dev/null

Changed pipeline to variable but same error

variables:
- name: purge_cmd
  value: acr purge --filter 'image:.*' --ago 30d --untagged --dry-run

#Resource pool to use
pool: 
  vmImage: ubuntu-latest

stages:
  - stage: ACR_cleanup
    jobs:
      - job: acr_cleanup
        steps:
          - task: AzureCLI@2
            displayName: Azure CLI
            inputs:
              azureSubscription: Cleanup_SC
              scriptType: bash
              scriptLocation: inlineScript
              inlineScript: |
                az --version
                az account show
                az acr run --cmd "$(purge_cmd)" --registry <> /dev/null

Tried in local PowerShell cmd with azure cli getting a proper response for below command

 $PURGE_CMD="acr purge --filter 'image:.*' --ago 30d --untagged --dry-run"                                                                                                                                                  
 az acr run --cmd "$PURGE_CMD" --registry <registry> /dev/null  

az cli version 2.26.1 only supports the same. The current latest image cli version is 2.26.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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