I want to execute some bash scripts with azure task, the task is created successfully but it doesn't do anything and also it doesn't log anything, it seems that the script never gets executed, here is the task that i create :
---
name: archive
platform:
os: linux
steps:
- cmd: |
REGISTRY=***
PROD_REPO=***
ARCHIVE_REPO=***
echo "Logging into ACR..."
az acr login --name $REGISTRY
LATEST_TAG=$(az acr manifest list-metadata \
--registry $REGISTRY --name $PROD_REPO --orderby time_desc \
--query [0].tags[0] --output tsv)
echo "LATEST_TAG: $LATEST_TAG"
ALL_TAGS=$(az acr manifest list-metadata --registry $REGISTRY \
--name $PROD_REPO --output tsv)
for TAG in $ALL_TAGS; do
if [ \"$TAG\" != \"$LATEST_TAG\" ]; then
echo "Archiving tag $TAG..."
az acr import --name $REGISTRY --source "$REGISTRY/$PROD_REPO:$TAG" \
--repository $ARCHIVE_REPO --force
done
echo "Archiving process completed."
context: /dev/null
registry: ***
I create the task by the following command :
az acr task create --file archive.yaml --registry *** --name archive --schedule "* * * * *" --context /dev/null
Task is created but when i look at the logs it just says task executed successfully but it does nothing and also doesn't print anything for echo expresssion.
I also tried a simple echo script, but that one doesn't work either:
---
name: archive-optimizer
platform:
os: linux
steps:
- cmd: |
echo "Test..."
context: /dev/null
registry: ofsav
Update:
I added version as follows and now it prints logs:
version: v1.1.0
steps:
- cmd: |
REGISTRY=***
PROD_REPO=***
ARCHIVE_REPO=***
echo "Logging into ACR..."
az acr login --name $REGISTRY
LATEST_TAG=$(az acr manifest list-metadata \
--registry $REGISTRY --name $PROD_REPO --orderby time_desc \
--query [0].tags[0] --output tsv) || { echo "Failed to get latest tag"; exit 1; }
echo "LATEST_TAG: $LATEST_TAG"
ALL_TAGS=$(az acr manifest list-metadata --registry $REGISTRY \
--name $PROD_REPO --output tsv) || { echo "Failed to get all tags"; exit 1; }
echo "ALL_TAGS: $ALL_TAGS"
for TAG in $ALL_TAGS; do
if [ \"$TAG\" != \"$LATEST_TAG\" ]; then
echo "Archiving tag $TAG..."
az acr import --name $REGISTRY --source "$REGISTRY/$PROD_REPO:$TAG" \
--repository $ARCHIVE_REPO --force || { echo "Failed to archive tag $TAG"; exit 1; }
fi
done
echo "Archiving process completed."
Now it gives another error:
az command not found
While based on the following document az command should be recognized: Yaml file for acr task


