In case someone is facing the same issue, I managed to solve my problem with the environment variables returning null. You need to use stage in your pipeline and define the deployment on the stage level, like below:
pipelines:
branches:
release/master:
- stage:
name: Some name for this stage
deployment: production
steps:
- step: *build-pipeline
- step: *destructive-pre
- step: *deploy-full-package
- step: *deploy-env-spec-config
- step: *destructive-post