I have a question regarding yaml conditions. I followed this documentation: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml
I need to deploy to each environment based on some conditions. For example,
- deploy to 'int' environment only if source branch is 'develop'
- deploy to 'ua' environment only if source branch is 'master'
- deploy to 'prod' environment only if source branch is 'master'
If any of these conditions is true, deploy to that environment.
I wrote a condition as follows:
condition: |
or(
and(
eq(variables['Build.SourceBranch'], 'refs/heads/develop'),
eq('${{ parameters.environmentAbbreviation }}', 'int')
),
and(
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
eq('${{ parameters.environmentAbbreviation }}', 'ua')
),
and(
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
eq('${{ parameters.environmentAbbreviation }}', 'prod')
)
)
This is what I get while running build/release:
Evaluating:
or(and(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), eq('int', 'int')), and(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('int', 'ua')), and(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('int', 'prod')))
Expanded:
or(and(eq('refs/heads/develop', 'refs/heads/develop'), eq('int', 'int')), and(eq('refs/heads/develop', 'refs/heads/master'), eq('int', 'ua')), and(eq('refs/heads/develop', 'refs/heads/master'), eq('int, 'prod')))
Because the first condition is correct, my assumption is that the deployment would start in int environment. But this didn’t deploy to int environment. Why is that?