Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudbees Jenkins Bitbucket Branch Source Plugin configuration hardcoded to use Cloud?

I get a 401 Unauthorized error when trying to connect the Bitbucket Source Plugin to my on-prem Bitbucket Datacentre (Server) installation.

If I use my own Bitbucket.org cloud account credentials I get a different error, leading me to believe that even though I've configured the plugin to use a Bitbucket Server, it's still reaching out to the Cloud bitbucket(.org).

Versions: Jenkins: 2.110 Bitbucket Branch Source Plugin: 2.2.11 Bitbucket (datacentre): v5.7.1

Following the documentation https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#bitbucket There is no Advanced button to configure the Bitbucket Server/Cloud. The only configuration I found was in the Configure System [Jenkins] section;

Gobal Configuration:

Bitbucket Endpoints

  • Bitbucket Server
  • Name My Bitbucket Git
  • Server URL https://mygit.net
  • Manage hooks [no]

In my multibranch pipeline, I've removed the Git source and added the Bitbucket Source.

Configured it with a rest API account for my Bitbucket instance. I've even added this user to the admin group Configured the Owner as a project within my Bitbucket instance

None of the other boxes let me populate them.

Running the manual scan results in the below error:

com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: Unauthorized.

I have personal Bitbucket.org credentials. If I use these instead (without changing any other configuration), I get the following error instead:

[Mon Apr 30 12:32:02 UTC 2018] Starting branch indexing...
Connecting to https://bitbucket.org using [email protected]/****** (My Atlassian Cloud)
ERROR: [Mon Apr 30 12:32:03 UTC 2018] Could not fetch branches from source 3f72008d-bf57-4ee3-abd4-1d2c6fb07c6e

Attention drawn to the log entry: Connecting to https://bitbucket.org

I've restarted Jenkins multiple times, thinking that the global configuration is being cached incorrectly in some way.

I'm now at the point where I believe that either I've configured the plugin in the wrong place and I can't find the correct place. Or the plugin isn't honouring the configuration and it's hardcoded (?) to always use the cloud bitbucket.

like image 303
JimForTheWin Avatar asked Nov 08 '22 07:11

JimForTheWin


1 Answers

Posting a solution even though this is an old thread, as I came across the exact same issue recently (and a potential solution).

My setup was:

  • Bitbucket Server v6.7.1
  • Jenkins 2.190.2
  • Bitbucket Branch Source Plugin 2.5.0

And I was seeing the same Could not refresh actions for navigator com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator@d0235a2 com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401 everytine Jenkins tried to scan the BitBucket Team/Project pipeline (on the BitBucket server).

SOLUTION: This was hidden in the Jenkins configuration itself (i.e. Jenkins > Manage Jenkins > Configure System)

  • Configure the Bitbucket Endpoints section with the essential Bitbucket Server details like Name, Server URL, and Credentials. Other properties in this section are optional.
  • Scroll down the page (Jenkins > Configure System) and look for another section called Bitbucket Server Violations Server Defaults. Make sure that the Credentials and the Base URL property values match the Credentials and Server URL values from the Bitbucket Endpoints section. Once these values were entered (and matched), the above error was fixed and the Bitbucket Team/Project pipeline scan started to connect to the Bitbucket server successfully.
like image 69
mk7 Avatar answered Nov 15 '22 07:11

mk7