Skip to content

Instantly share code, notes, and snippets.

@dcasati
Created September 24, 2024 17:11
Show Gist options
  • Save dcasati/35bbd47f9879c5a8c9345323e02bb876 to your computer and use it in GitHub Desktop.
Save dcasati/35bbd47f9879c5a8c9345323e02bb876 to your computer and use it in GitHub Desktop.

Revisions

  1. dcasati created this gist Sep 24, 2024.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/bin/bash
    set -x
    # Set your ACR name and resource variables
    ACR_NAME=""
    SOURCE_RG_C1="<source-resource-group>"
    MyRegC1="<my-registry>"
    MyPipelineC1="<my-pipeline>"
    MyPipelineC1Run="<my-pipeline-run>"
    MyBlob="<my-storage-blob>"

    # Get all repositories (images)
    repositories=$(az acr repository list --name $ACR_NAME --output tsv)

    # Loop through each repository and list its tags
    for repo in $repositories; do
    tags=$(az acr repository show-tags --name $ACR_NAME --repository $repo --output tsv)

    for tag in $tags; do
    image_tag="$repo:$tag"
    printf "Running pipeline for Image: %-30s Tag: %-10s\n" "$repo" "$tag"

    # Run the pipeline with the specific artifact (image:tag)
    echo az acr pipeline-run create --resource-group $SOURCE_RG_C1 \
    --registry $MyRegC1 \
    --pipeline $MyPipelineC1 \
    --name $MyPipelineC1Run \
    --pipeline-type export \
    --storage-blob $MyBlob \
    --artifacts $image_tag \
    --force-redeploy
    done
    done