Hi,
I am using a Pipeline with Definitions and Steps and appending some Artifacts and it works really great.
I have 3 Branches (LIVE, DEV, LOCAL) in the Pipeline and they all use the exact same Steps and what I did to make sure that the proper branch deploys to the proper environment is that I used if [[ $BITBUCKET_BRANCH = live ]];
to check for all three branches and created a little .env
file which contains the path to the folder where the deploy should go.
When everything is good with the deploy I delete the .env
file from the server.
Now the main question here is that I wuld love to use the deployment variable in the definition step but I do not know how I can check that because the IF
I used in the script section of the step does not work one step higher in hierarchy in the deployment
variable.
I would like to see under the Deployments section in Bitbucket Admin the status of when the latest deploy was and to what branch.
Is it possible?
The Definitions code looks like this for step 1 and this is where I should set the deployment variable:
definitions:
steps:
- step: &initiate
name: Running composer
deployment: live --> "This is where I would like to do an check from what branch we are deploying and change LIVE to DEV or LOCAL"
caches:
- composer
script:
- cd $BITBUCKET_CLONE_DIR && composer install --no-dev
- if [[ $BITBUCKET_BRANCH = live ]]; then cd folder && echo 'HOME=/live' > .env; fi
- if [[ $BITBUCKET_BRANCH = dev ]]; then cd folder && echo 'HOME=/dev' > .env; fi
- if [[ $BITBUCKET_BRANCH = local ]]; then cd folder && echo 'HOME=/local' > .env; fi
artifacts: # defining the artifacts to be passed to each future step.
- folder/**