Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Remote Trigger Bamboo build from BitBucket webhook? Edited

I'm new to bamboo and webhooks. I'm trying to start a bamboo build automatically when a PR to master branch from my repo is opened.

I followed this guide but the remote trigger is not starting at all.

Bamboo:

bamboo-1.png

BitBucket:

bamboo-2.png

 

I've already checked the following:

- verify that the whitelisted ip is correct (the bitbucket webhook fails if i remove that)

- my bamboo plan is enabled and is building fine on manual run

 

 

Bamboo plan in YAML: 

---
oid: 7818389690603565060
key: XT
name: XXX - TEMP
project:
oid: 7819374853022025730
key: DIGQA
repositories:
- oid: 7818811903068661169
parentRepository: 7818811903068661168
triggers:
- name: Bitbucket Server repository triggered
description: ''
pluginKey: com.atlassian.bamboo.plugins.stash.atlassian-bamboo-plugin-stash:stashTrigger
enabled: true
configuration: {}
triggerConditions:
com.atlassian.bamboo.triggercondition.internal:plansGreenCondition:
enabled: 'false'
triggeringRepositories:
- 7818811903068661169
- name: Remote trigger
description: Master PR Trigger
pluginKey: com.atlassian.bamboo.triggers.atlassian-bamboo-triggers:remote
enabled: true
configuration:
repository.change.trigger.triggerIpAddress: 10.40.1.120
triggerConditions:
com.atlassian.bamboo.triggercondition.internal:plansGreenCondition:
enabled: 'false'
triggeringRepositories:
- 7818811903068661169
branchConfiguration:
planBranchCreation:
enabled: false
removedBranchCleanup:
enabled: false
inactiveBranchesCleanup:
enabled: false
merging:
enabled: false
notificationStrategy: notifyCommitters
triggers: inherited
issueLinking: enabled
dependencies:
configuration:
enabledForBranches: 'true'
requireAllStagesPassing: null
blockingStrategy: none
childPlans: []
permissions:
users:
xxxxxxxx:
- administration
- build
- clone
- read
- write
groups: {}
roles:
user:
- read
anonymous:
- read
plugins:
- pluginKey: com.atlassian.bamboo.plugin.system.additionalBuildConfiguration:concurrentBuild
configuration:
custom.concurrentBuilds.overrideNumberOfConcurrentBuilds: 'true'
custom.concurrentBuilds.numberOfConcurrentBuilds: '1'
- pluginKey: com.atlassian.bamboo.plugin.system.additionalBuildConfiguration:buildExpiry
configuration:
custom.buildExpiryConfig.enabled: 'false'
- pluginKey: com.atlassian.bamboo.plugin.artifact.handler.local:artifactHandlersConfiguration
configuration:
custom.artifactHandlers.useCustomArtifactHandlers: 'false'
buildDefinition:
custom.predefinedVariables: '{"variableSetList":[]}'
stages:
- oid: 7818530428091950756
name: Default Stage
jobs:
- oid: 7818671165580276746
key: JOB1
name: Default Job
tasks:
- oid: 7819234115533708305
description: Checkout Default Repository
pluginKey: com.atlassian.bamboo.plugins.vcs:task.vcs.checkout
configuration:
repositories:
- ref: defaultRepository
buildDefinition:
cleanWorkingDirectory: false
repositoryDefiningWorkingDirectory: -1
...

 

===========================================================================

EDIT 1:

Okay, so I realized the hook and the trigger is actually working. I misunderstood the trigger setup on bamboo.

Current behavior:

  1. PR to master is opened
  2. BitBucket webhook (on PR) is fired
  3. Bamboo trigger is set to remote / bitbucket server repo. Because of this, the build will not start until the changes are commited / PR is actually merged

Problem: I want the build to trigger once the PR is opened (before merge). To a bit more context, this is the ideal flow of my build:

  1. Checkout the PR code (revision)
  2. Run my tests against the PR revision

I'm looking at the following links as it seems they managed to do it somehow but I can't make sense of the bits of info provided in both the links.

 

 

1 answer

1 accepted

1 vote
Answer accepted

For the Webhooks in Bitbucket Cloud repository, is the option "Choose from a full list of triggers" selected so that it can be configured to trigger when Pull Request Created?

Since the commit exist in the repository branch, is the branch plan created at Bamboo Plan Configuration >> Branches so that it can run build with the related repository branch?

Hi, thanks for your response!

For the Webhooks in Bitbucket Cloud repository, is the option "Choose from a full list of triggers" selected so that it can be configured to trigger when Pull Request Created?

 -- No, and i dont see that option either. but the Pull Request event is already selected; Meaning, the webhook is fired successfully upon opening a PR

Since the commit exist in the repository branch, is the branch plan created at Bamboo Plan Configuration >> Branches so that it can run build with the related repository branch?

-- Yes. The plan branch is already created.

 

Problem: If I open the PR, the bitbucket webhook is fired, but bamboo will then wait for file changes before the build is started. This means that the build will start ONLY when the PR is merged.

What I want to accomplish is automatically start the build in bamboo once a PR is opened in bitbucket and not wait for the merge to happen. This build is supposed to execute tests and will eventually signal bitbucket on the test results as an indicator whether the PR code is good to merge or not.

Foong Atlassian Team Oct 02, 2018

No, and i dont see that option either. but the Pull Request event is already selected; Meaning, the webhook is fired successfully upon opening a PR

Just notice the screen shot that it is Bitbucket Server instead of Bitbucket Cloud. For Bitbucket Server, there is no need to create any Webhook. Bitbucket Server will trigger Bamboo by default if Application Link is created between both servers.

From the Bamboo Specs, there is no need to disable Bitbucket Server repository triggered and create Remote trigger. It will work fine with Bitbucket Server repository triggered.

Yes. The plan branch is already created.

When the branch plan is created in Bamboo, did it run for the first time? Automatic Branch creation can be configured at Plan Configuration > Branches to create branch plan when the PR is created (it will be triggered to build immediately too).

If I open the PR, the bitbucket webhook is fired, but bamboo will then wait for file changes before the build is started.

Yes, even though the PR is fired, if there is no new commit in the branch, the branch plan will not be triggered. Is there any new commit in the repository branch after the PR is created? 

Just notice the screen shot that it is Bitbucket Server instead of Bitbucket Cloud. For Bitbucket Server, there is no need to create any Webhook. Bitbucket Server will trigger Bamboo by default if Application Link is created between both servers.

From the Bamboo Specs, there is no need to disable Bitbucket Server repository triggered and create Remote trigger. It will work fine with Bitbucket Server repository triggered.

I used remote trigger as a workaround because I'm getting some sort of proxy issue when I use the bitbucket server trigger (bitbucket webhook request fails upon opening a PR). Will this be an issue with the setup I'm trying to do?

When the branch plan is created in Bamboo, did it run for the first time? Automatic Branch creation can be configured at Plan Configuration > Branches to create branch plan when the PR is created (it will be triggered to build immediately too).

I created the branch plan manually and tested that it builds fine by running it manually and automatically by merging the PR. The real missing bit is run it when the PR is opened.

Yes, even though the PR is fired, if there is no new commit in the branch, the branch plan will not be triggered. Is there any new commit in the repository branch after the PR is created? 

Yup! I'm testing with actual commits. Would you be able to provide me a step by step guide on how to configure the plan to run on PR open?

Meanwhile, I'll explore the automatic branch plan creation. Thanks!

I used remote trigger as a workaround because I'm getting some sort of proxy issue when I use the bitbucket server trigger (bitbucket webhook request fails upon opening a PR). Will this be an issue with the setup I'm trying to do?

There is no need to use Bitbucket Webhook as well when using Bitbucket Server repository triggered. Bitbucket Server will still trigger Bamboo without the webhook if the Application Link is created.

Perform the following steps to confirm if the Bitbucket Server repository triggered works fine:

  1. Enable Bitbucket Server repository triggered
  2. Disable Remote trigger
  3. Delete the Bitbucket Webhook in Bitbucket Server
  4. Select the option When pull request is created at Bamboo Plan Configuration > Branches > Create plan branch
  5. Save the setting
  6. Create a PR in Bitbucket Server
  7. Check Bamboo log file atlassian-bamboo.log for the following message: 
2018-10-03 21:59:15,983 INFO [http-nio-8085-exec-10] [AuthenticatorImpl] Authenticated app 'Bitbucket:5629199447' as user 'null' successfully
2018-10-03 21:59:15,987 INFO [http-nio-8085-exec-10] [AccessLogFilter] 127.0.0.1 POST http://localhost:8085/rest/remote-event-consumer/latest/events/stash-pullrequest-opened-remote-event 255617kb
2018-10-03 21:59:16,009 INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-11] [PullRequestAwareEventListener] Received pull request opened event [ stash, from: refs/heads/testbranch to: refs/heads/master]

Meanwhile, I'll explore the automatic branch plan creation. Thanks!

If the option When pull request is created is selected at Bamboo Plan Configuration > Branches > Create plan branch , the above trigger event will automatically create a branch plan and build for the first time.

Perform the following steps to confirm if the Bitbucket Server repository triggered works fine:

  1. Enable Bitbucket Server repository triggered
  2. Disable Remote trigger
  3. Delete the Bitbucket Webhook in Bitbucket Server
  4. Select the option When pull request is created at Bamboo Plan Configuration > Branches > Create plan branch
  5. Save the setting
  6. Create a PR in Bitbucket Server
  7. Check Bamboo log file atlassian-bamboo.log for the following message: 

Hi, I don't see the "When pull request is created" at the create plan branch screen. 

This is the bamboo version we're using:

Version 5.14.3.1

Build number 51416

Build date 12/5/16

Also, I confirmed that the link between bitbucket and bamboo is already configured.

Is there anything I'm missing? 

Thanks!1.png

2.png

Foong Atlassian Team Oct 04, 2018

Version 5.14.3.1

Its a new feature in Bamboo 6.0+

Bamboo 6.0 Release Notes

Based on your use case, Bamboo need to be upgraded to 6.0+ so that it can be configured with this new feature.

I see. Thanks for the info! If you can suggest any workaround for this use case without a Bamboo upgrade that will be highly appreciated! :)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

621 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you