Hello Stack Overflow community, I'm encountering an issue with my Azure DevOps YAML pipeline configuration. Specifically, the DeployCode stage is skipping unexpectedly, even though there are no explicit conditions set for it. I've reviewed my YAML code carefully and couldn't find any obvious reasons for this behavior.
Here's a simplified version of my YAML code:
trigger:
branches:
include:
- develop
- master
- feature/x
schedules:
- cron: '30 * * * *'
displayName: Every hour at 30th minute...
branches:
include:
- develop
- master
- feature/x
always: true
pr: none
pool:
vmImage: ubuntu-20.04
variables:
BRANCH_NAME: ${{ replace(variables['Build.SourceBranch'], 'refs/heads/', '') }}
${{ if in(variables['BRANCH_NAME'], 'develop', 'feature/x') }}:
TF_ENVIRONMENT: test
${{ elseif eq(variables['BRANCH_NAME'], 'x') }}:
TF_ENVIRONMENT: x
RESOURCE_GROUP: '${TF_ENVIRONMENT}x-rg'
STORAGE_ACCOUNT_NAME: '${TF_ENVIRONMENT}x'
CDN_ENDPOINT_NAME: '${TF_ENVIRONMENT}x'
CDN_PROFILE_NAME: '${TF_ENVIRONMENT}x-profile'
AZURE_SUBSCRIPTION: 'Your-Subscription-Name-Here'
AZURE_SUBSCRIPTION_ID: 'Your-Subscription-ID-Here'
stages:
- stage: DiagnosticJob
jobs:
- job: DiagnosticJob
steps:
- script: |
echo "Build Reason: $BUILD_REASON"
displayName: Print Build Reason
- stage: DeployInfrastructure
condition: ne(variables['Build.Reason'], 'Schedule')
jobs:
- job: ConditionalInfrastructureDeployment
steps:
- script: |
echo "BRANCH_NAME: $BRANCH_NAME"
echo "TF_ENVIRONMENT: $TF_ENVIRONMENT"
echo "AZURE_SUBSCRIPTION: $AZURE_SUBSCRIPTION"
echo "AZURE_SUBSCRIPTION_ID: $AZURE_SUBSCRIPTION_ID"
displayName: Print Expression Result
#infrastructure deployment steps here
- stage: DeployCode
jobs:
- job: DeployWebsite
steps:
# code deployment steps here
The DeployInfrastructure stage is conditionally skipped based on the Build.Reason, but there are no conditions or dependencies defined for the DeployCode stage. According to Azure DevOps documentation, it should execute unconditionally as long as the previous stages have completed successfully.
I've also checked the build and deployment logs for any errors or issues, but everything seems to be in order.
Could someone please help me understand why the DeployCode stage is being skipped unexpectedly? Any insights or suggestions for troubleshooting would be greatly appreciated.
Thank you!
Update:
To provide further clarification, the "DeployCode" stage is skipped only when the "DeployInfrastructure" stage is also skipped, and this occurs specifically when the build status is set to "Scheduled."
As it is written in documentation here:
In you case it happens because previous step was not succeeded
You should change it to
The new condition works that way that if the pipeline was scheduled then it checks result of the first job, and if not than expects that all jobs finished successfully.