Unable to connect bitbucket from Jenkins
Asked by Olivia Chow:

I have setup the application links for Jenkins from Bitbucket.

For the outgoing authentication, I have created a consumer from Jenkins with the plugin of "Manage Bitbucket Server consumers"

However, I have no idea what information is required and how to get them in order to configure the part of Incoming Authentication, especially the Consumer Key and public key.

Besides, in the Bitbucket Server integration setting of Jenkins, I have inserted the personal access token generated by my bitbucket admin, however, the connection is still failed.


Answers:
author: Ganesh Babu
body: Hello [@Olivia Chow](/t5/user/viewprofilepage/user-id/4049419)

Welcome to the Atlassian Community...!!!

You can make use of this Add-on developed by Atlassian for a ease and smooth connection between bitbucket and jenkins.

[https://marketplace.atlassian.com/apps/1222132/jenkins-integration-for-bitbucket-server?hosting=server\&tab=overview](https://marketplace.atlassian.com/apps/1222132/jenkins-integration-for-bitbucket-server?hosting=server&tab=overview)

Document - <https://plugins.jenkins.io/atlassian-bitbucket-server-integration/>

Please check on the consumer key and shared secret on the application links detail page in Jenkins as same data needs to be copied on Bitbucket during the creation of application link

comments: author: Olivia Chow
body: Thanks.

I already create a personal access token from the Bitbucket and use the token to connect Bitbucket from Jenkins. However, it said the connection is failed. I am sure that the instance base URL of bitbucket is correct. It's very odd..

Besides, I capture a log message from the Bitbucket container which ***10.176.x.x*** *is the ip of my desktop and **172.19.0.26** is the internal ip of **nginx-proxy-ssl.***

***2021-01-07 17:07:43,485 WARN \[http-nio-7990-exec-41\] my_user_name_in_jenkins @SLDATYx1027x9557x0 1b19i56 10.176.x.x, 172.19.0.26 "GET /rest/applinks/3.0/status/1186df59-f2e4-34fc-95c2-245b77f5af0e HTTP/1.1" c.a.a.i.m.remote.TryWithCredentials You do not have an authorized access token for the remote resource.***

It seems the problem is shown here but I have no idea about the cause and how to fix it.


author: Ganesh Babu
body: [@Olivia Chow](/t5/user/viewprofilepage/user-id/4049419)

Looks like one of the reason might be with Nginx as we have the reverse proxy configured.

<https://confluence.atlassian.com/kb/how-to-create-an-unproxied-application-link-719095740.html>

<https://confluence.atlassian.com/kb/how-to-bypass-a-reverse-proxy-or-ssl-in-application-links-719095724.html>


author: Olivia Chow
body: Thank you for the information. But I am not quite familiar what should I check on my nginx-ssl-proxy container based on the links you provided.

In fact, my jra, bitbucket and confluence can successfully connected to each other with using hostname alias, e.g. <https://jira.domain/>.

Also, I have successfully tried to connect the Jenkins to Confluence and Jira with **Confluence Publisher** plugin (refer to Capture.PNG) and **Jira** plugin (refer to Capture2.PNG) with credential of username and password.

So, it is so odd that only connection via personal access token is failure.

![Capture2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/124964i6BEB6DC01C8A313C/image-dimensions/579x378?v=v2 "Capture2.PNG")

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/124965i5C08131F127D94D7/image-dimensions/565x166?v=v2 "Capture.PNG")


author: Olivia Chow
body: Thank you for the information. But I am not quite familiar what should I check on my nginx-ssl-proxy container based on the links you provided.

In fact, my jra, bitbucket and confluence can successfully connected to each other with using hostname alias, e.g. <https://jira.domain/>.

Also, I have successfully tried to connect the Jenkins to Confluence and Jira with **Confluence Publisher** plugin (refer to Capture.PNG) and **Jira** plugin (refer to Capture2.PNG) with credential of username and password.

So, it is so odd that only connection via personal access token is failure.

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/124970iE5063DBB68CCF350/image-dimensions/411x121?v=v2 "Capture.PNG")![Capture2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/124971i3DB46B2690313C59/image-dimensions/411x270?v=v2 "Capture2.PNG")


author: Olivia Chow
body: Thank you for the information. But I am not quite familiar what should I check on my nginx-ssl-proxy container based on the links you provided.

In fact, my jra, bitbucket and confluence can successfully connected to each other with using hostname alias, e.g. <https://jira.domain/>.

Also, I have successfully tried to connect the Jenkins to Confluence and Jira with **Confluence Publisher** plugin and **Jira** plugin with credential of username and password.

So, it is so odd that only connection via personal access token is failure.


author: Sandesh Shetty
body: [@Olivia Chow](/t5/user/viewprofilepage/user-id/4049419)

May be this [video](https://www.youtube.com/watch?v=0-FugzVYJQU&feature=emb_title) link is helpful for you!!

kindly accept the answer if it is helpful!!


Tags: bitbucket-server

server