I'm having an issue with Pipeline deployment. This is my `yml` file:
pipelines:
branches:
staging:
- step:
name: Build an app
image: node:22.0.0
caches:
- node
size: 2x
script:
- npm install
- export NODE_OPTIONS=--max-old-space-size=6144
- npm run build:staging
artifacts:
- dist/**
- step:
name: Upload source maps to Sentry
image: getsentry/sentry-cli:2.40.0
script:
- sentry-cli sourcemaps inject --org XXX --project $SENTRY_PROJECT_NAME ./dist
- sentry-cli sourcemaps upload --org XXX --project $SENTRY_PROJECT_NAME --auth-token $SENTRY_AUTH_TOKEN ./dist
- step:
name: Deploy new build to staging droplet
deployment: staging
script:
- rsync -rzO dist/skote/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/dist/ --exclude=bitbucket-pipelines.yml
Hello @Kristjan Ortego ,
and welcome to the Community!
Based on the YAML file you shared, the variable $SENTRY_PROJECT_NAME is being used in a step that is not configured as deployment :
- step:
name: Upload source maps to Sentry
image: getsentry/sentry-cli:2.40.0
script:
- sentry-cli sourcemaps inject --org XXX --project $SENTRY_PROJECT_NAME ./dist
- sentry-cli sourcemaps upload --org XXX --project $SENTRY_PROJECT_NAME --auth-token $SENTRY_AUTH_TOKEN ./dist
In this step configuration we can see it does not have a deployment definition, so no deployment variables will be available in this step. This also explains why it works when you move that variable to repository variable.
That being said, if you want to have more than one step per deployment, you can use the stages feature, which allow you to configure multiple deployment steps to the same environment. Following you can find an example on how this would look like in your YAML file :
pipelines:
branches:
staging:
- step:
name: Build an app
image: node:22.0.0
caches:
- node
size: 2x
script:
- npm install
- export NODE_OPTIONS=--max-old-space-size=6144
- npm run build:staging
artifacts:
- dist/**
- stage:
name: Deploy to staging
deployment: staging #all steps within the stage will have access to the deployment environment variables
steps:
- step:
name: Upload source maps to Sentry
image: getsentry/sentry-cli:2.40.0
script:
- sentry-cli sourcemaps inject --org XXX --project $SENTRY_PROJECT_NAME ./dist
- sentry-cli sourcemaps upload --org XXX --project $SENTRY_PROJECT_NAME --auth-token $SENTRY_AUTH_TOKEN ./dist
- step:
name: Deploy new build to staging droplet
script:
- rsync -rzO dist/skote/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/dist/ --exclude=bitbucket-pipelines.yml
I hope this helps! Let us know in case you have any questions.
Thank you, @Kristjan Ortego !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.