- stage: publish_service_names
dependsOn: build_code
jobs:
- job: get_services
pool:
${{ if eq(parameters.useCustomAgentPool, true) }}:
name: ${{ parameters.customAgentPoolName }}
${{ if eq(parameters.useCustomAgentPool, false) }}:
vmImage: ubuntu-latest
steps:
- bash: |
services=$(cat $(Pipeline.Workspace)/variables/services.txt)
echo "service List : $services"
echo "##vso[task.setvariable variable=serviceName;]$services"
name: getservices
- ${{ if and(eq(parameters.buildDockerImages, true), eq(parameters.buildSingleServiceDockerImages, true)) }}:
- stage: publish_docker_images
dependsOn: publish_service_names
variables:
services: $[stageDependencies.publish_service_names.get_services.outputs['getservices.serviceName']]
jobs:
** - ${{ each service in split(variables.services, ',') }}:
** - template: ./build-push-single-docker.yaml
parameters:
acrServiceConnection: ${{ parameters.acrServiceConnection}}
serviceName: "${{ service }}"
friendlyName: "${{ service }}"
repositoryPathPrefix: ${{ parameters.repositoryPathPrefix }}
build-push-single-docker.yaml
jobs:
- job: publish_${{ parameters.friendlyName }}
pool:
${{ if eq(parameters.useCustomAgentPool, true) }}:
name: ${{ parameters.customAgentPoolName }}
${{ if eq(parameters.useCustomAgentPool, false) }}:
vmImage: ubuntu-latest
steps:
- bash: |
echo "##vso[task.setvariable variable=buildArtifact;]ailens_services_supplemented_with_client_package"
condition: eq('${{ parameters.addClientToSingleboxAndGUI }}', true)
displayName: "Set artifact name"
Tried direct use of
- the stageDependencies variable directly in the template loop expression
- assigning it to variable and using the variable
both of them didnt solve my purpose.
2
Answers
The job execution is not looping over all service names.
It looks like you are missing
isOutput=true
property.Try
More info here: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash#set-an-output-variable-for-use-in-future-stages