This is what I have for this particular stage:
parameters:
- name: services
type: object
default:
- admin
- admin-v2
- api
- client
stages:
- stage: UnitTests
displayName: Run unit tests on service...
dependsOn: Changed
condition: succeeded()
variables:
apiChanged: $[ stageDependencies.Changed.Changes.outputs['detectChanges.apiChanged'] ]
jobs:
- job: UnitTests
condition: or(eq(stageDependencies.Changed.Changes.outputs['detectChanges.anyServicesChanged'], true), eq(variables['Build.Reason'], 'Manual'))
displayName: Running unit tests...
steps:
- ${{ each service in parameters.services }}:
- ${{ if and(eq(service, 'api'), eq(variables.apiChanged, true)) }}:
- bash: |
echo "Now running ${{ service }} unit tests..."
The line that is in question is:
- ${{ if and(eq(service, 'api'), eq(variables.apiChanged, true)) }}:
- If it is just the first condition, the subsequent
bash
executes whenservice = 'api'
. - If it is just the second condition, the subsequent
bash
does not execute which leads me to believe it comes backfalse
. - Thus, having both conditions it evaluates to
false
.
So the eq(variables.apiChanged, true)
is obviously the problem.
I have verified that apiChanged = true
by doing the following:
- bash: |
echo $(apiChanged)
I've done this before the - ${{ each service in parameters.services }}:
and it comes back true
.
I've also tried eq(variables.adminV2Changed, true)
and eq(variables.adminV2Changed, 'true'
).
Any suggestions for why this happening and how to fix it?