Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2020 edited
@Ashish Sharma , Bitbucket notifies Jenkins on git push if the plugin has been configured correctly for that repository in Bitbucket. If tag pattern/branch (which was pushed) is matched as per the configuration inside Jenkins then, the job should run.
What information does the Bitbucket webhook installed by this plugin transport?
How does the Jenkins plugin translate that information into a git checkout?
My observation is, that the installed webhook notifies Jenkins only about something was pushed to bitbucket, but does not contain the exact commit IDs. Thus, when Jenkins receives the trigger event it fetches the whole git repo and then it tries to find out which commits are new (not built yet). It uses the given pattern as a ref filter.
This is IMO similar behavior to what the stash notification plugin did and is a common source for misunderstandings and annoyance. E.g. when connecting an existing repo to a Jenkins job and setting * as branch pattern, Jenkins would build all branches and tags on the first trigger event.
Atlassian Team members are employees working across the company in a wide variety of roles.
July 2, 2020 edited
Hi @rweickelt, I'm a developer from Bitbucket Server working on the plugin. Thanks for your questions:
1. Your observation is correct- the webhook does not contain any commit or branch information at all- it's simply a notification for our plugin that there has been a remote change, and will fire each time a commit is pushed.
2. Once we receive a webhook, the plugin performs a poll on the Bitbucket Server, which effectively returns a list of all significant/builable changes in the repo that match the branch selector. A non-empty list indicates a build needs to be performed, and at that point the job is triggered.
Our SCM delegates all git operations to the Git SCM. A revision to build is chosen with a statement like this (with a wild branch selector):
The important thing to note here is that a webhook doesn't impart any additional information- it merely asks Jenkins if it wants to perform a job, which is decided based on that poll result, so a first build triggered by a webhook should be the same as one performed by triggering a build manually. I ran a quick test in a Freestyle job after pushing a commit to one branch in a project with multiple branches and commits, and the latest commit was the only one built.
I'm Product Manager of Bitbucket Server. Can you please expand on what you mean by Data Center optimization?
To clarify, the Jenkins plugin described in this article works seamlessly with both - Bitbucket Server and Data Center. It includes support for smart mirroring. In fact its so simple that user just needs to select mirror from list of servers from a dropdown inside Jenkins job. Also, you can configure multiple Jenkins instances to use it with single Bitbucket Server/Data Center.
We want users to be able to use and configure the build jobs easily and avoid lot of manual configurations so, we do the heavy lifting for them. With Bitbucket Server 7.4 we have added a new builds page -https://confluence.atlassian.com/bitbucketserver/bitbucket-server-7-4-release-notes-1013849643.html that will show rich build information from Bamboo and Jenkins inside Bitbucket. You will see more CI/CD features including enhancements to this integration in coming months.
I have followed the instructions for setting up our Bitbucket Server instance in Jenkins and the personal access token for an admin user, but when testing the connection I get "Connection failure, please try again", despite having followed the instructions at stated without any apparent problem.
For the "Instance URL" I put verbatim what appears as "base URL" in the Server settings of our On Prem Data Center Bitbucket instance: https://bitbucket.our.domain:8443. From the same Jenkins machine, I have no trouble accessing this bitbucket instance over ssh to clone repos.
We are now running Bitbucket Server 7.2.3 and Jenkins 2.222.3, with Bitbucket Server Integration plugin 2.0.1.
I do not see any relevant information in our /var/log/jenkins/jenkins.log after this failed connection test.
Please provide any suggestions you have for troubleshooting this.
Atlassian Team members are employees working across the company in a wide variety of roles.
September 1, 2020 edited
Hi @Tim Black , thanks for your comment. I'm afraid it's difficult to diagnose the issue without more information. You mention being able to clone with SSH locally, which may be the issue- the plugin only supports cloning by SSH from version 2.1.0 and above.
It would be really nice if this official plugin supported all of the available webhooks that bitbucket is capable of sending. The lack of ability to build on PR creation is really annoying.
My problem turned out to be caused by the fact that our bitbucket server was using a self-signed certificate. Once we got an external verified, trusted cert, the connection worked fine.
1. It appears that this plugin supports notifying Bitbucket of jenkins build status. Does this plugin make the Bitbucket Server Notifier plugin obsolete?
2. The only Bitbucket-related pipeline steps I'm seeing in the pipeline-syntax page on my jenkins instance is `bbs_checkout`. Is this the only one? Is there some other reference somewhere of what pipeline features this plugin supports?
2.5. Does this plugin support any pipeline steps (or could you provide me with groovy code) to help me retrieve the available references in a given repo hosted on Bitbucket Server?
I'd like to add job parameters allowing the user to override the submodule references contained in the gitlinks in the primary super-repo. Unless there's any special parameter types provided by this plugin, I would use extendedChoice parameter and run git at the command line to populate a drop-down control. Seems like a very basic feature your plugin could provide as a new Jenkins Pipeline Parameter Type.
EDIT: since writing this I have found the git parameter plugin, which essentially does what I'm asking if the Bitbucket Server plugin could do. https://plugins.jenkins.io/git-parameter/
3. Can I post questions to issues.jenkins-ci.org, or is this the best place to ask questions?
Thanks a lot for actively working on the improvement of this plugin.
I have an usecase:
Jenkins should start a build anytime a new tag is created in bitbucket. Build is triggered and executing on push but when I create a new tag the build is triggered but nothing else happens.
On push:
On Tag creation:
On Tag creation the Trigger is received but build doesnt start hence nothing to return to bitbucket.
Searching online - the recommendation is to
Set refspec to: +refs/tags/*:refs/remotes/origin/tags/*
Is there any method to access eventKey value comes from json payload? An environment variable etc for that?
I couldnt see on documentation nor global environment variables page if it exists.
If not, simply it should :)
In my case, I try to run Sonarqube analysis only when pr:opened state. So there should be a method to determine which event triggered the current build.
@Tim Blacksorry to gravedig, we happen to have the same type of setup (bitbucket + self-signed certificate), and are trying to integrate with jenkins via the bitbucket server plugin. We are experiencing exactly the same type of problems.
Would you mind sharing (if there is more) details of what led to the conclusion about the self-signed certificate?
@abbadabbadu it sounds like you solved your issue, but it's not clear what you did to fix it. We are no longer using self-signed certificate so my experience maybe isn't relevant anymore.
I'm mostly interested in figuring out what the actual roadmap is for this plugin, specifically when/if it is ever going to support PR-event-triggered webhooks. I see in the release notes that there is general support for webhooks in plugin releases since 1.0-alpha3 in Sept 2019, and that some related bugs have been fixed since, but it's not clear what sort of webhook this is - the release notes just say:
"Automatic webhook creation in a Bitbucket Server repo when a Jenkins job is saved."
@Imran Khan , @Martin Henschke anyone, where can I find information about the functional operation of this webhook? Is this only for triggering the job on pushes to the repo? Where is the webhook payload defined?
In issues JENKINS-62943 and JENKINS-60342 many users have asked for "support for Pull Requests". There I had proposed that the plugin developers simply provide a generalized webhook functionality that ensures a complete payload is sent to jenkins in the job trigger so that it's pipeline logic can decide and implement behavior. @Martin Henschke can you give an update on the status of this new "In Progress" feature, and what you're actually implementing? Thanks for your time.
72 comments