How to workout why pull request (git on bitbucket) isn't triggering a build on bamboo?
Asked by baralong:

I've been trying to set things up to trigger a build for a pull request.

Our setup is as follows:

* Bamboo 6.5.0 local install
* Bitbucket 4.11.2 using git, local server
* The plan repository is linked with the **master** branch
* I've got a "Bitbucket Server repository triggered" trigger defined looking at the linked repo
* My build plan is based on the linked repo and has a manual branch setup for **develop**
* On the "Branches" tab of the build plan I've get "Create Plan When pull request is created" and triggers "same as in parent plan"

The 2 servers are linked. I can see build results for master and develop on bitbucket, and I can see the commits listed in the build results. Also on the "branchStatus" page the pull request branch is listed.

I've tried pull requests from feature branches named with "feature/\*" and "feature-\*" and pull requests to both develop and master.

Regardless of this I never get the pull request build happening.

What can I do to debug this problem? Any other ideas?


Answers:
author: baralong
body: Thanks Kah,

I don't have access to that area of bamboo, but I've checked in with an admin. When we check the remote event status is "Not Working"

We've had a look and it seems bamboo can see bit bucket but not the other way around. It looked like the ports were't configured correctly.

We've fixed that and bitbucket now says it can see bamboo, so that's some progress, however we still aren't getting the pull requests triggering a new branch. Looking at the log file we have:

```
2018-09-05 16:42:08,100 INFO [http-apr-8085-exec-19] [AuthenticatorImpl] Authenticated app 'Stash:5972229772' as user '****' successfully
2018-09-05 16:42:08,100 INFO [http-apr-8085-exec-19] [AccessLogFilter] 172.16.99.5 GET http://deployment.capricorn.com.au:8085/rest/applinks/latest/applicationlink/28752c28-df29-34e7-b22e-557991148dd7/authentication/provider?xoauth_requestor_id=******* 298933kb
```

We don't get and "remote-event-consumer" log messages. But what we do get is:

```
2018-09-05 16:42:35,288 WARN [SSH connection monitoring thread:thread-64156] [SshProxyCommand] SSH proxy tried to connect to [git@/172.16.99.5:7999]: and failed due to the following error: [Authenticating remote session failed]
org.apache.sshd.common.SshException: No more authentication methods available
 at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:315)
 at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:252)
 at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:199)
 at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:530)
 at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:463)
 at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1325)
 at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:424)
 at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:67)
 at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:285)
 at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:265)
 at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:262)
 at org.apache.sshd.common.io.nio2.Nio2CompletionHandler$1.run(Nio2CompletionHandler.java:37)
 at java.security.AccessController.doPrivileged(Native Method)
 at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:34)
 at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
 at sun.nio.ch.Invoker$2.run(Invoker.java:218)
 at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
2018-09-05 16:42:35,304 INFO [10-BAM::PlanExec:pool-17-thread-2] [DefaultErrorHandler] Recording an error: Unable to detect changes : DC-DC : com.atlassian.bamboo.plugins.git.GitCommandException: command ['C:\Program Files (x86)\Git\cmd\git.exe' ls-remote ssh://b192244f-2daf-4f21-84e3-84efa0c993f5@127.0.0.1:6694/dc/csl.datacleansing.database.git] failed with code 128. Working directory was [C:\Program Files\Bamboo\temp]., stderr:
Authenticating remote session failed
stdout:
Warning: Permanently added '[127.0.0.1]:6694' (RSA) to the list of known hosts.
BAMBOO-SSH-PROXY: [SSH proxy tried to connect to [git@/172.16.99.5:7999]: and failed due to the following error: [Authenticating remote session failed]: No more authentication methods available]
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
```

The odd think is that when I go to the "Branch Status" for the repository branch in bamboo I can see the pull request off to the right, also regular builds are triggered when a branch is updated, it's just the pull request triggers that aren't working. No new branch in bamboo and no build.

Later in the log I see:

```
2018-09-05 16:48:56,408 WARN [1-PullRequestDetectionBackgroundThread:pool-5-thread-1] [PullRequestDetector] com.atlassian.bamboo.repository.RepositoryException: [Request to JIRA failed. Returned with 401. Response: {"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}]
```

What would your next step be? I'd think the last resort would be to remove and re-add the link.

Thanks,

Doug


author: Foong
body: What is the ++Remote events status++ and ++Last received event++ at *Bamboo Administration \> System \> System information \> Linked Bitbucket Server instances* ?

If a new Pull Request is created in Bitbucket Server, is there any branch plan created automatically in Bamboo?

When a new commit pushed to Bitbucket Server, check if the following example message exist in Bamboo log **atlassian-bamboo.log**:

```
2018-09-04 18:44:27,877 INFO [http-nio-8085-exec-13] [AuthenticatorImpl] Authenticated app 'Bitbucket:8948820956' as user 'null' successfully
2018-09-04 18:44:27,889 INFO [http-nio-8085-exec-13] [AccessLogFilter] 127.0.0.1 POST http://localhost:8085/rest/remote-event-consumer/latest/events/stash-branch-changed-remote-event 374833kb
```

comments: author: Foong
body: > We've fixed that and bitbucket now says it can see bamboo, so that's some progress

Is the remote event status fixed too? Is there any Last received event? Auto branch plan creation will not work if this is not fixed.
> It looked like the ports were't configured correctly.

It would be better to re-create the application links in both servers cause the incorrect port setting previously might affect the application link creation.
> We don't get and "remote-event-consumer" log messages. But what we do get is:

Edit the Bamboo Repository at *DC-DC Plan Configuration \> Repositories* and then click on the Save button. If it is a Linked Repository, edit and re-save it in the Administration.


author: SuperITMan
body: Dear Kah,

I have a similar issue except that I discovered that it seems to be related to pull request from forks.

I explain myself with the 2 following examples.

Working:

- Create new branch "feature/my-awesome-feature" in ProjectX \> RepoX

- Create PR from ProjectX \> RepoX \> "feature/my-awesome-feature" to ProjectX \> RepoX \> "master"

- Bamboo triggers automatically a branch build

Not working:

- Fork ProjectX \> RepoX in SuperITMan \> RepoX

- Create new branch "feature/my-awesome-feature" in SuperITMan \> RepoX

- Create PR from SuperITMan \> RepoX \> "feature/my-awesome-feature" to ProjectX \> RepoX \> "master"

- Bamboo does not trigger any build

What should I change in my Bamboo configuration to allow branch build "when pull request is created" from a fork ?

Thanks in advance for your help.

Kind regards,

Alexis GEORGES


Tags: bitbucket

bitbucket-server

server