I am trying to trigger bitbucket pipelines on every pull request to staging and production branches. But it wouldn't trigger.
I have tried passing branches values like staging/*, master/* and even '**', but the pipelines wouldn't just trigger
Following is my config:
Hi @sumandhakal and welcome to the community!
Pull requests pipelines cannot be triggered based on the destination branch at the moment. The branch you specify in your bitbucket-pipelines.yml for a pull-requests pipeline matches the source branch of the PR. We have a feature request for pull-requests pipelines based on the destination branch that you can vote for and add yourself as a watcher:
In the meantime, you could use a pull-requests build based on the source branch, and then, during the build, you can check the destination branch of the PR using the default variable $BITBUCKET_PR_DESTINATION_BRANCH, and execute different commands/scripts depending on the destination branch.
Apart from that, there are also some syntax errors in your bitbucket-pipelines.yml that need to be fixed:
1. One of them is what Luke mentioned. The branch names under pull-requests should be properties, not a list, so you need to remove the hyphen before the branch names.
2. The properties name and deployment are properties of a step or a stage, not of a pipeline, so they should be defined for a step or a stage. If you want to use the same deployment environment for multiple steps of the same pipeline, the way to do this is with a stage, like in the following example:
pipelines:
pull-requests:
testing1:
- stage:
name: Deploy to staging
deployment: staging
steps:
- step:
<<: *step1
- step:
<<: *step2
3. The keyword steps inside a pipeline can only be used with a stage, like in the example I shared above. If you don't use a stage, you can simply list the steps without the steps: part. However, if you want to use the same deployment environment for both steps in the pipeline, then a stage with the steps: is the way to go.
Please feel free to reach out if you have any questions!
Kind regards,
Theodora
Your syntax seems to be incorrect, branch names need to be child properties rather than a list.
See https://support.atlassian.com/bitbucket-cloud/docs/pipeline-start-conditions/#Pull-Requests
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.