I am trying to setup it CI/CD for salesforce using bitbucket.
I have create a connected app for each environments (qa, uat, production)
And in bitbucket > repository settings > deployments:
I have added the sandboxes for staging environment and the production environment. For each environment I have set ENVIRONMENT variables:
USERNAME
CONSUMER_KEY
LOGIN_URL
ENVIRONMENT
Like this:

but when I push a commit to test the deployment, the ENVIRONMENT variable returns an error.
ENVIRONMENT variable is not set
I use echo in the script to be able to log the error and $ENVIRONMENT is empty.
set -e
# echo is used to print the message on the console
echo "Starting the build process for environment: $ENVIRONMENT"
if [ -z "$ENVIRONMENT" ]; then
echo "ENVIRONMENT variable is not set."
exit 1
fiCurrently the build fails here when I have clearly created the ENVIRONMENT variable:

finally these are the deployment steps in the bitbucket-pipelines.yml:
# Production deployment
release/master:
- step: *build-pipeline
- step: *destructive-pre
- step: *deploy-full-package
- step: *deploy-env-spec-config
- step: *destructive-post
I also tried adding deployment to the steps as shown below:
# Production deployment
release/master:
deployment: production
steps:
- step: *build-pipeline
- step: *destructive-pre
- step: *deploy-full-package
- step: *deploy-env-spec-config
- step: *destructive-post
But when doing so, another error occurs:
There is an error in your bitbucket-pipelines.yml at [pipelines > branches > release/master > deployment]. This section should not contain "deployment".
How can I fix these errors?
Thanks