#!/bin/bash
# Read Docker Compose file
compose_file="docker-compose.yml"
images=($(grep -E '^ *image:' $compose_file | awk '{print $2}' | cut -d ':' -f 1))
# Initialize group variable
all_variables=()
for image in "${images[@]}"; do
# Store image name in pipeline variable
variable_name="image_${image//[^a-zA-Z0-9_]/_}"
# Set individual variable
# echo "Setting pipeline variable for $variable_name: $image"
echo "##vso[task.setvariable variable=$variable_name]$image"
# Concatenate variable assignment to group variable with newline
group _variable+="$variable_name: $image"$'\n'
done
echo "$all_variables"
# Set group variable in Azure Pipelines
# echo "Setting group variable in Azure Pipelines"
echo -e "##vso[task.setvariable variable=allVariables;isOutput=true]$all_variables"
echo "allVariables:$allVariables"
but the (all variables)group variable are not set in the pipeline so please give me any suggestion what ever i am do is right the process is right like this thing is possible
i am expecting like this
variables:
allvariables: |
image_postgres: postgres
image_mongo: mongo
image_quay_io_keycloak_keycloak: quay.io/keycloak/keycloak
image_discovery_server: discovery-server
image_api_gateway: api-gateway
image_auth_service: auth-service
but this variable is dynamically

exportmakes it into an environment variable, which'll be inherited by subprocesses of that shell, but there's no way for a shell (or any other program) to create variables in its parent process.grep | awk | cutcan be refactored toawk '/^ *image:/ {split($2, f, /:/); print f[1]}' "$compose_file"