Hello,
i'm trying to use deployment variables as follows:
image: node:8.12.0
definitions:
steps:
- step: &build-stg-angular
caches:
- node
script: # Modify the commands below to build your repository.
- credentials="${server_username}@${server_ip}"
- npm install
- npm run build-stg -- -c ${client}
pipelines:
custom:
asim-stg:
- step: *build-stg-angular
- step:
name: Deploy to staging server.
deployment: asim-stg
script:
- echo "Deploying"
but it doesn't recognise the variables!
I managed to get this working!
Just to be clear in the sample above the deployment variables refer to
${server_username}@${server_ip}
If that is the case, which I suspect it is I have the answer.
Here is a simple example..
Here I'm trying to reference MY_DEPLOYMENT_VARIABLE_1 and MY_DEPLOYMENT_VARIABLE_2 however only MY_DEPLOYMENT_VARIABLE_2 will be recognized from the deployment variables.
The reason for this is simple.
Deployment variables are only recognized in the deployment block i.e. the block where we specify "deployment:Development". WHAT!
Further to this remember "deployment:Development" can only be used once.
Took me days to realize this :-(
Remember to ^^ Up Vote if this helps ;-)
Thank you so much for this answer. After looking through 1001 tutorials and ALL of bitbucket pipelines sh*t documentation. This solved it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think this would be the right answer. I'll give you feedback in 5 mins.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are totally right. The deployment variables are only used in deployment block.
But any ideas about how to set build variables not explicitly configured in yaml file and not every time to type in the run pipeline input?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much, documentation is terrible indeed @[deleted]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know why, but it reads Repository variables successfully!
but it doesn't recognize environments variables!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having the same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please vote for this "Suggestion" from March 2019 regarding this craziness: https://jira.atlassian.com/browse/BCLOUD-18261
In the comments there are a number of workarounds.
Personally, I'm exporting the variable into a text file in the step that references the deployment, and then setting the variable to the content of the text file in the later step:
pipelines:
branches:
main:
- step:
name: Build react app
deployment: Production
script:
- echo -n "$CLOUDFRONT_DISTRIBUTION" > ./cloudfront.txt
artifacts:
- cloudfront.txt
- step:
name: Deploy to S3
- step:
name: Invalidate Cloudfront Cache
script:
- pipe: atlassian/aws-cloudfront-invalidate:0.1.1
variables:
DISTRIBUTION_ID: "$(cat ./cloudfront.txt)"
(Note that there's a lot removed from this example. The relevent pieces are line 8 where the variable is put into a text file, line 10 where it's stored as an artifact, and line 18 where it's read back into the varaible)
This is madness and a bad design decision at Atlassian HQ that I hope gets fixed soon. This is the second time this has bitten me and I had to hunt around for the solution as it's so unintuitive.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should the variable be just $server_ip instead of bamboo like ${server_ip} ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.