Include or exclude jobs dynamically based on custom variable

Hi All,

I am trying to include or exclude jobs based on custom variable, which is updated in previous jobs. But it is not working as expected and dev_deploy job is skipped.

.gitlab-ci.yml

variables:
SERVICE1_IS_DOWN: “false”

stages:

  • service_status
  • dev_deploy

check_service_status:
stage: service_status
script:
- echo “Inside check_service_status”
# if service is down
- echo ‘SERVICE1_IS_DOWN=“true”’ >> build.env
artifacts:
reports:
dotenv: build.env

dev_deploy:
stage: dev_deploy
tags:
- ci
rules:
- if: ‘$SERVICE1_IS_DOWN == “true”’
script:
- echo “This is dev_deploy step”
- echo $SERVICE1_IS_DOWN
dependencies:
- check_service_status