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

Atlassian supported Jenkins integration for Bitbucket Server

72 comments

Zoe Trakosas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 14, 2019

Hi. I’m Zoe and I’m a designer on Bitbucket Server.

Right now, we’re working on a project to streamline Bitbucket’s CI workflow. We’re looking into extending Bitbucket’s capability to integrate with Jenkins, and we’re interested in learning more about the capabilities you’re interested in as well as getting your input and feedback on our vision.

We’d love to speak to you. If you can spare an hour to talk, email me at ztrakosas@atalssian.com

Javi Rodríguez November 26, 2019

Hello,

Does anyone know how to get the webhook payload information in Jenkins?

I have configured a pipeline in Jenkins that is correctly triggered by the plugin, but I can't get this information to be processed in the pipeline.

Any help is welcome

Regards

Javi

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 27, 2019

Hi Javi,

Can you expand on what payload information from webhook is needed and how will you use it in the pipeline. 

Cheers,

Imran

Javi Rodríguez November 28, 2019

We have been working with other plugins to implement CI workflow. Generic Webhook Plugin injects payload info in the BuildInfo environmental var in our Jenkins pipeline environment, BitBucket plugin injects this info in the BITBUCKET_PAYLOAD environmental var in our Jenkins environment, but we don't found how BitBucket Server Integration plugin is injecting this info in Jenkins.

According to the webhook event details, It's sending this info as payload:

{
"eventKey": "repo:refs_changed",
"date": "2019-11-27T16:01:32+0100",
"actor": {
"name": "UserID",
"emailAddress": "user@correo.interno",
"id": 3731,
"displayName": "UserName",
"active": true,
"slug": "user",
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket:8443/users/user"
}]
}
},
"repository": {
"slug": "app_name",
"id": 72,
"name": "app_name",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "project_name",
"id": 122,
"name": "project_name",
"public": false,
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket:8443/projects/project_name"
}]
}
},
"public": false,
"links": {
"clone": [{
"href": "ssh://git@bitbucket:7999/project_name/app_name.git",
"name": "ssh"
}, {
"href": "https://bitbucket:8443/scm/project_name/app_name.git",
"name": "http"
}],
"self": [{
"href": "https://bitbucket:8443/projects/project_name/repos/app_name/browse"
}]
}
},
"changes": [{
"ref": {
"id": "refs/heads/develop",
"displayId": "develop",
"type": "BRANCH"
},
"refId": "refs/heads/develop",
"fromHash": "a35e06ffa0b44173daabb017336569186228eab9",
"toHash": "99f5d2ca498cbab381de06c598026d90e4d40c42",
"type": "UPDATE"
}]
}
We need this info to cover several audit requirements in our CMDB, as well as to generate a change report to pass to QA pipeline with the modified files between fromHash and toHash commits

We are actually using these fields in our process.

"date": "2019-11-27T16:01:32+0100",
"actor": {
"name": "UserId",
"emailAddress": "user@correo.interno",
"displayName": "UserName"
},
"changes": [{
"refId": "refs/heads/develop",
"fromHash": "a35e06ffa0b44173daabb017336569186228eab9",
"toHash": "99f5d2ca498cbab381de06c598026d90e4d40c42",
}]

We are using:

Atlassian Bitbucket v6.7.1
Jenkins ver. 2.190.3
Thanks in advance

Best regards

Like # people like this
Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2019

Hi Javi, 

First of all thanks for providing these details. If I understand correctly,

https://wiki.jenkins.io/display/JENKINS/Bitbucket+Plugin injects webhook payload into BITBUCKET_PAYLOAD environment variable but our plugin - 

https://wiki.jenkins.io/display/JENKINS/Bitbucket+Server+integration+plugin+for+Jenkins doesn't do this and you need this info in pipeline for audit and generate a report. 

Unfortunately, we don't have this capability right now.  We think it will be good to provide this in future but I can't provide any timeline. Can you please create a suggestion at https://issues.jenkins-ci.org with atlassian-bitbucket-server-integration-plugin as the component? 

Cheers,

Imran

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2019

Hi @gafnerpa 

Thanks for the feedback. Please see my comments inline. 

> I really like the overall integration between JIRA, Bitbucket Server and Bamboo (creating an issue creates a new branch, pull request requires a successful build etc) but I miss the pipeline in Bamboo compared to Jenkins.

Can you please expand on what capabilities you find missing in Bamboo re pipeline. 

> Is there already a possiblity to use the power of JIRA and Bitbucket Server together with Jenkins or are there plans to support it?

With the new plugin (what this is post is about) you can get a well integrated workflow between Bitbucket and Jenkins. In future, we will post build information to Jira like we do with Bamboo. Are there any other capabilities that you'd want? 

Cheers,

Imran 

Javi Rodríguez December 2, 2019

Hi all

Added three new features at https://issues.jenkins-ci.org

  • JENKINS-60340 BitBucket payload information is not injected in the Jenkins build
  • JENKINS-60341 Allow configuring the plugin to use Jenkins domain credentials
  • JENKINS-60342 Include support to BitBucket Pull Request

 

Best Regards

Javi

Gabriel Lewertowski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 6, 2019

Hi,

Bitbucket Branch Source plugin uses Git SCM and sets the refspec to +refs/pull-requests/*/from:refs/remotes/origin/* to build pull-requests to the main repository from forks. I can't find how to configure the refspec with Bitbucket Server SCM. Is there another way to automatically build pull requests ?

Thanks.

Tom Kostiainen December 13, 2019

We are using the folders plugin to organize and restrict permissions to jobs. Having the "configure jobs" permission set on the folder level does not seem enough for this plugin to work (fields missing when selecting Bitbucket as the SCM), it required to give users this permissions on the system level -- not good.

ragebflame
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 14, 2020

Great plugin, seems like it will be a great addition to our workflow.

Is there any plans to implement the git checkout via SSH? I am unable to do so over HTTPS. Unless I am missing some configuration.

Like # people like this
rweickelt February 27, 2020

I have set up a pipeline job and I want to build any commit pushed to Bitbucket. Therefore I have set the branch specifier to **. 

The pipeline is checked out from the repo. But it doesn't work as expected. The job checks out random commits. The instructions provided by Atlassian show only */master. I don't know whether that is related to https://issues.jenkins-ci.org/browse/JENKINS-60809.

How is that supposed to work? 

Given that this is an official Atlassian plugin and the version has already reached 1.0 I am very disappointed with both the quality and the capabilities of this plugin. In its current state it is effectively useless for any kind of serious CI. We want to build and test commits **before** they enter master, not after.

A much better (more flexible, reliable and transparent) solution is to use the Pull-request-notifier plugin in Bitbucket together with the Generic Webhook trigger plugin in Jenkins.

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2020

Hi @rweickelt 

I'm sorry that you're disappointed with he plugin. If you check the tooltip for 'Branches to build' it clearly mentions leave the field blank to examine any branch for building. 

Screen Shot 2020-02-28 at 6.42.45 am.png

Can you try this and let us know if it works? Also, it will really help us if you can tell the other concerns you have regarding the quality and capabilities of this plugin?

 

Thanks!

Imran

Kevin Reynolds
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 27, 2020

Hi Imran 

We are using it to great success here.  Something I noticed and not sure if this is a "feature" or a "bug".

I have observed recently that if you initially set up a hook to look at master and then go back and update to include another branch, in this case it did not appear to update the hook to include both branches.  I had to turn it off save then turn it on again and the update took place.   Other than that its a fantastic solution for us.  Keep up the great work 

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2020

Thanks @Kevin Reynolds 

Can you please raise a bug at https://issues.jenkins-ci.org with atlassian-bitbucket-server-integration-plugin as the component? We'll triage and get back to you with updates. 

 

Cheers,

Imran

Tim Black
Contributor
March 2, 2020

Following the instructions for setting up the bitbucket instance and the personal access token, then testing the connection at 2:58 in your video:

https://jenkins.io/blog/2020/01/08/atlassians-new-bitbucket-server-integration-for-jenkins/

I get "Connection failure, please try again", despite having followed the instructions at stated without problem. We are running Bitbucket Server 6.10.1 and Jenkins 2.190.3, with Bitbucket SErver Integration plugin 1.1.0.

I do not see any relevant information in our /var/log/jenkins/jenkins.log after this failed connection test.

Anyone else experience this, or know what I should try next? Thanks.

Like # people like this
rweickelt March 10, 2020

@Imran Khan 

thank You for Your reply. When I leave the branch specifier empty, Jenkins will automatically replace it with ** the next time I open the page. I suppose that this has nothing to do with my problem.

How can I make the plugin build **any** commit that is pushed to bitbucket, regardless of the branch name. I am using a pipeline job with a pipeline file in the bitbucket repo.

The error I get is that Jenkins checks out random commits, at least not from the branches that I have pushed.

Thanks

Richard

Kevin Reynolds April 16, 2020

Hello, I have searched high and low for the answer to this but cannot find it anywhere to so taking the chance this thread is still being watched. 
I saw support for multibranch pipelines is now available in the latest version of the plugin.  

I cannot find anywhere where this is detailed.  
The problem is that I am not presented with the option to set the Bitbucket Server Trigger Build After push option in the job config screen.  

The documentation around this is a little sparse so since I am using a multibranch pipeline I thought that maybe it needed to be added to my Jenkinsfile for each of the branches etc. as @Kristy was so kind to point out before.   Problem is when I go into the snippet generator and select the build properties option I do not see an option to generate that little nugget.  

Can anyone who has successfully implemented this in a multibranch help a brother out?  Going bald pulling my hair out on this.  

It works perfectly in a freestyle project btw

Thanks in advance

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 22, 2020

Hi @Kevin Reynolds ,

 

Thanks for your feedback. We have created a bug for this - https://issues.jenkins-ci.org/browse/JENKINS-62003. It's high on our list. Please follow the issue for updates. 

 

Cheers,

Imran

Dinsen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 7, 2020

Just like @ragebflame I'm also missing the git checkout with SSH.

Are there any progress with this?

Martin Henschke
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 7, 2020

Hi @Dinsen, I'm one of the developers on Bitbucket Server.

Thanks for your interest in the SSH cloning feature. Unfortunately, the solution is not ready for release due to some testing issues in Java 11 that we are still working to resolve. This feature is being tracked in JENKINS-60492, and if you're interested you can follow the progress of the feature itself on the Github pull request.

Thanks,

Martin

Ashish Sharma
Contributor
June 11, 2020

Hi, Can you clarify if below can be supported via plugin:

  • Notify jenkins on new tags creation and then trigger build from those newly created tags. Asking as don't see any option to provide Refspec
  • Trigger jenkins on new pull request and then trigger job based on the incoming branch?

Thanks,

Ashish

Like sriprasanna.mg likes this
Nikolay Kanchev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 24, 2020

Hi

I try to integrate Jennkins and Bitbucket server with "Bitbucket Server Integration" plugin. I configure personal access token and after pipeline job creation webhook is created in Bitbucket server. Git access is working and status from Jenkins job is presented in Bitbucket server.

The problem that I have is with triggering Jenkins job on git push. I receive this error:

Date: Wed, 24 Jun 2020 07:40:05 GMT
Server: Jetty(9.4.27.v20200227)
X-Content-Type-Options: nosniff
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html; charset=ISO-8859-1
Via: 1.1 localhost (Apache-HttpClient/4.5.5 (cache))
Content-Length: 1468

Body

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 400 Failed to parse the body: Cannot construct instance of `com.atlassian.bitbucket.jenkins.internal.model.BitbucketUser`, problem: emailAddress
at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 311] (through reference chain: com.atlassian.bitbucket.jenkins.internal.trigger.RefsChangedWebhookEvent[&quot;actor&quot;])</title>
</head>

 

Best Regards

Nikolay

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 24, 2020

@Ashish Sharma 

You should be able to provide which branches/tags to build in 'Branches to build' field. If this is not what you're expecting, can you please expand on your use case to help us understand the flow better.

Screen Shot 2020-06-25 at 4.11.06 pm.png

Supporting pull request is high on our list. You can follow the updates on this issue - https://issues.jenkins-ci.org/browse/JENKINS-60342

Thanks

Imran Khan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 24, 2020

Hi @Nikolay Kanchev 

Can you please create an issue at at https://issues.jenkins-ci.org with atlassian-bitbucket-server-integration-plugin as the component. This will help team triage and track the issue. 

Thanks

Like Nikolay Kanchev likes this
Nikolay Kanchev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 25, 2020

Thanks Imran

I create the issue JENKINS-62798 .

Like Mihai Moldovanu likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events