BitBucket Plugin for Jenkins doesn't fire release pipeline job likely because release pipeline script not in SCM, how to trick it?

27 views
Skip to first unread message

David Karr

unread,
Apr 14, 2017, 1:19:25 PM4/14/17
to Jenkins Users
My enterprise uses BitBucket Server and Jenkins.  For my project, I wrote a pipeline script that is fully parameterized, and can properly build PR branches, release branches, and the master branch.  Several condition checks do different things depending on what the branch is.

I store the Jenkinsfile on the master branch. There has never been a need to branch it for any release branch.

BitBucket has a "Pull Request Notification" feature that lets me fire the correct URL to run the pipeline on the PR branch.

BitBucket has a "BitBucket Plugin for Jenkins" that lets me specify the Jenkins URL, but that's about all the control I have.  If something changes in the repo, it "does some magic" to make Jenkins run the jobs associated with that branch.  The problem is, it's just not smart enough, and the protocol that BitBucket and Jenkins are using to decide what job to run is not transparent to me.

In Jenkins, the main pipeline job can be run with different branch parameters, so for each of our currently pending releases, I have a separate pipeline job with a very short script that just fires the main pipeline with the correct branch parameter.  I don't store this pipeline script in SCM, as it's only three lines long.

When someone merges a PR to a release branch in BitBucket, I want one of these release pipeline jobs to run, but this doesn't work, and I'm guessing this is the case because the release pipeline job doesn't specify any SCM settings.

Is there some way I can "trick" Jenkins into associating this release pipeline job with the particular SCM and branch, so the protocol between BitBucket and Jenkins will result in the proper job being fired?

Jennifer Hofmeister

unread,
May 18, 2017, 5:21:33 AM5/18/17
to jenkins...@googlegroups.com

This may be a bit late, but in case anyone else has a similar issue, I can offer some experience with “Webhook to Jenkins for Bitbucket”, which may be the one you’re referring to. I can’t find a plugin named “Bitbucket plugin for Jenkins” in the plugin store.

 

So what the Jenkins Webhook plugin does to find the matching Jenkins job for a given repository, is to browse your Jenkins base URL (entered in the first field) for a Job that has a certain Git configuration. The parameter it checks for is the address string in the SCM --> Git field in the Job configuration, and then it matches the string it finds there against the URL that is entered in the Bitbucket plugin’s second field. This is case-sensitive and absolutely strict, the strings must be identical. I don’t use pipeline jobs, but I can’t think of an obvious reason why this shouldn’t work the same way. (Not to say there couldn’t be a hidden reason;)… )

If you use SSH like me, choosing the “SSH” option in the plugin’s address field may not work. I haven’t found out why… but as a little workaround, just choose “Custom” and enter the exact same SSH address into the field.

 

Hope this helps someone.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cb258727-c03b-4c7f-a459-2864ce7b9b85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages