Hello
I have a production and a staging app (nodejs) on Heroku. I want to create a pipeline on bitbucket so that when I push code to staging it deploys staging branch to my staging app on Heroku and master to production app?
Regards
Matloob
Hi,
Have a look at the following guide we have here: https://confluence.atlassian.com/bitbucket/deploy-to-heroku-872013667.html
The only thing you'll need to do different is set up the branch configurations. Which you can learn about here: https://confluence.atlassian.com/bitbucket/branch-workflows-856697482.html
image: node:6
clone:
depth: full
pipelines:
branches:
master:
- step:
name: Deploy to production
script:
- npm install
- npm test
- git push <heroku production URL>
staging:
- step:
name: Deploy to staging
script:
- npm install
- npm test
- git push <heroku staging URL>
Thanks,
Phil
Hi Phil
Thanks for taking the time to reply. I had found this page (https://confluence.atlassian.com/bitbucket/branch-workflows-856697482.html) too. My .yml file looks like:
image: node:8.9.2
clone:
depth: full
pipelines:
default:
- step:
name: Deploy REST API to Heroku
deployment: production
script:
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
branches:
graphql:
- step:
name: Deploy GraphQL to Heroku
deployment: staging
script:
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME_STAGING.git graphql:master
But it never pushes from the branch graphql. What's wrong with the configuration?
Regards
Matloob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you mean that the build never triggers on the 'graphql' branch, or that the git push command fails. Do you get an error message?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does it instead trigger the 'default' pipeline?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you double check that Pipelines is enabled?
Repository Settings -> Pipelines -> Settings
You may also be out of build minutes. You can check that on the main Pipelines page:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you double check if there's a bitbucket-pipelines.yml file on the 'graphql' branch, and what the configuration of it is?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had created the .yml file on bitbucket on master, it wasn't there on the graphql branch. I cherry-picked the commit that added the .yml and pushed graphql and it worked.
If it needs to be on each branch, it can be branch-specific. No need for 'default' on graphql and 'branches' on master, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd recommend you have the same btibucket-pipelines.yml configuration on each branch. So on *all* your branches, you can have something like:
pipelines:
branches:
master:
- step:
script:
- # deploy to prod heroku
graphql:
- step:
script:
- # deploy to staging heroku
default:
- step:
script:
- # run any other pipelines here. Maybe some tests.
If you have the yaml the same across all branches then you won't need to worry about inconsistencies or merge conflicts across your branches.
Thanks,
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Coming late to this conversation and I am facing the same issue.
I have three branches:
master (which is to be deployed to heroku prod app)
staging (which is to be deployed to heroku staging app)
development (no deployment)
I have included the following yml file in master and staging:
image: node:6.9.4
pipelines:
default:
- step:
script: #default script to run
- echo "This default script will run when something is pushed to this branch"
branches:
master:
- step:
name: Heroku Production Deployment
caches:
- node
script: #deploy master branch to heroku prod app
- npm install
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_PROD_APP.git HEAD:master
staging:
- step:
name: Heroku Staging Deployment
caches:
- node
script: #deploy staging branch to heroku staging app
- npm install
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_STAGING_APP.git HEAD:staging
On development the .yml file only has the default value (since I do not want to deploy when anything is pushed to development branch).
When I make any changes in master (or anything is merged to master) the yml runs fine but only the prod app is updated.
When anything is merged to staging then again the master is deployed. Its like the staging branch deployment code never runs.
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.