You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm using Bitbucket pipelines to deploy my react app to the s3 bucket, deployments work fine but unfortunately, my `process.env
` variables are undefined. I already add my all env variables in deployment variables.
bitbucket-pipeline.yml
image: node:14
pipelines:
branches:
master:
- parallel:
- step:
name: Build and Test
caches:
- node
script:
- rm -rf package-lock.json
- npm install
- npm rebuild node-sass
- CI=false npm run build:prod
artifacts:
- build/**
- step:
name: Security Scan
script:
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
- pipe: atlassian/git-secrets-scan:0.5.1
- step:
name: Deploy to Production
deployment: Production
trigger: manual
clone:
enabled: false
script:
# sync your files to S3
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
S3_BUCKET: $S3_BUCKET
LOCAL_PATH: 'build'
Hi @Zain Khan
Welcome to the community.
Based on my understanding, you've added your environment variables in the "production" Deployment variables.
However, after it was deployed to the S3 bucket, the process.env file variables are undefined.
If this is correct, I can see that you've built your application in the first step which is "Build and Test" with no deployment environment.
Then you only use deployment in the third step which is "Deploy to Production".
I believe variables are undefined in the file process.env because your environment variables are only available in the "Deploy to Production" step and that is where you only used the "deployment: Production" configuration.
For this, the best I can suggest is for you to use repository variables instead so that your environment variables are accessible to all your steps.
Hope it helps and let me know how it goes.
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.