I want to achieve this goal,
When i push to dev branch i want all steps to execute with Test environment variables using Pipeline Deployments
- step: &build
- echo $AWS_STAGE
- step: &deploy
- echo $AWS_STAGE
I have Deployments setup correctly and its printing correct variables if i have deployments in only one step
Above YAML is valid by https://bitbucket-pipelines.prod.public.atl-paas.net/validator
But throws an error when pipeline is runing
Looks like the problem is to have two times the deployment environment "test" in the same pipeline.
Bitbucket Pipelines refuses that and gives the error message.
Normally the deployment should be given on the step that deploys the (previous) build artifacts.
From what I can read in your question that would be the second step about deploying.
You can transfer artifacts from the first build step to the second deploy step by making use of the artifacts entry (see Using artifacts in steps) which should prevent the error.
So in short: It's possible to have multiple steps with deployments in the same pipeline but each deployment must have a different deployment environment (also sometimes named as deployment target).
E.g. first deploy to test, then deploy to production.
Artifacts are stored for 14 days, so if the deployment to production is a manual step, you have 14 days time to press the deploy button for production if the production deployment is a manual step.
If you could share a bit more how come to have the same deployment environment two times in the same pipeline, it's perhaps easier to figure out a more concrete suggestion.
Hey, @ktomk thanks for the reply.
I am indeed using artefacts, but i extracted simple example just for the usecase.
Actually what i need is an environment variables for build and deploy. For example if i want to build and deploy test env, then i want to be able to run the build step with Test env variables, because the build needs to contain urls to BE and so on...
Then in deploy step, i want to deploy the build to test environment by using deployment variables.
In short Deployment, variables should not be only for deploying but also for other steps.
For example in Wercker, they have global env variables, then per each step you can define env variables.
Can i do this with Bitbucket pipelines?
I don't know Wercker personally, so I can not comment on it.
You can define repository variables in Bitbucket Pipelines and they are for all pipelines and steps. This might map onto what you call Wercker global env variables.
In Bitbucket Pipelines from what I know it is *not* possible to define variables per step.
However there are deployment variables which is per deployment. But this comes with a caveat, see the following larger discussion which circles around the limitations: The deployment environment 'test' in your bitbucket-pipelines.yml file is invalid (the title is a bit misleading).
AFAIK deployment variables are limited to a single step. So this is perhaps not that well working for you. The discussion above (and below) still might shed more light and maybe you find a way
See as well:
Thanks for your answer, but yes with Bitbucket pipelines i need to repeat some scripts in some steps to achieve the goal.
I hope you will work on this limitation and enable deployment variables on each step + manual overriding the variables in each step. That would open more ways of engineering the Pipelines.
Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events