Child pages
  • Bitbucket Push And Pull Request Plugin

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleRequirements

1) This plugin requires a Jenkins v2.138.2 or later and supports

  • Bitbucket Cloud rest api v2.x+ and later
  • Bitbucket Server 5.14+ and later

2) This plugin will not work if the previous Bitbucket plugin  (https://plugins.jenkins.io/bitbucket) is installed.

3) warning: After updating the plugin from a version prior to the 2.x.x, the jobs with a pull request need to be reconfigured, reselecting once again, from the plugin conf. pane, the pull request event, that will trigger the build.


Plugin for Jenkins v2.138.2 or later, that triggers builds on Bitbucket's push and pull requests. It's based on the Sazo's fork (https://github.com/sazo/bitbucket-plugin) of the official Bitbucket Plugin (https://plugins.jenkins.io/bitbucket).

The new features introduced by Bitbucket Push and Pull Request are:

  • improved support of pushs for Bitbucket cloud Cloud (rest api v2.x+ with git and mercurial) and Bitbucket server Server (5.14+ with git)
  • support of pull requests for Bitbucket cloud Cloud (rest api v2.x+ ) (thanks Sazo)
  • usage of Gson instead of net.sf.json.JSONObject (blacklisted starting from Jenkins 2.102+)
  • Introduction of Models and security improvements
The new features introduced by Bitbucket Push and Pull Request are:
  •  improved support of pushs for Bitbucket cloud (rest api v2.x+) and Bitbucket server with git and mercurial) and Bitbucket Server (5.14+ with git)
  • support of pull requests for Bitbucket cloud (rest api v2.x+) (thanks Sazo)
  • usage of Gson instead of net.sf.json.JSONObject (blacklisted starting from Jenkins 2.102+)
  • introduction Introduction of Models and security improvements

This plugin supports:
  • push and pull requests for Bitbucket cloud rest api v2.x+ and later push and for for Bitbucket server 5.14+ and later (Experimental)

Configuration

Before you start...

...

2. Now activate the plugin in your job selecting the "Build with Bitbucket Push and Pull Request Plugin" option in the Build Triggers pane.


Environment variables

Environment variables for Bitbucket Cloud and Server pull requests

NAMEVALUE
BITBUCKET_SOURCE_BRANCHsource branch
BITBUCKET_TARGET_BRANCHtarget branch
BITBUCKET_PULL_REQUEST_LINKlink
BITBUCKET_PULL_REQUEST_IDid
BITBUCKET_PAYLOADpayload as json string

...

Code Block
languagegroovy
themeEclipse
titlePipeline script
properties([
    pipelineTriggers([
        [
            $class: 'BitBucketPPRTrigger',
            triggers : [
                [
                    $class: 'BitBucketPPRPullRequestTriggerFilter',
                    actionFilter: [
                        $class: 'BitBucketPPRPullRequestCreatedActionFilter'
                    ]
                ]
            ]
        ]
    ])
])
node {
	def sourceBranch = ""
        def targetBranch = ""
        try{
            sourceBranch = "${BITBUCKET_SOURCE_BRANCH}";
            targetBranch = "${BITBUCKET_TARGET_BRANCH}";
        }catch(e){}

        if(sourceBranch == ""){
            sourceBranch = 'development'
        }

        if(targetBranch == ""){
            targetBranch = 'master'
        }

        checkout changelog: true, poll: true, scm: [
            $class: 'GitSCM',
            branches: [
                [name: '*/'+sourceBranch]
            ],
            doGenerateSubmoduleConfigurations: false,
            extensions: [
                 [
                    $class: 'PreBuildMerge',
                    options: [
                        fastForwardMode: 'FF',
                        mergeRemote: 'origin',
                        mergeStrategy: 'recursive',
                        mergeTarget: ''+targetBranch
                    ]
                ]
            ],
            submoduleCfg: [],
            userRemoteConfigs: [
                [
                    url: 'https://[user]@bitbucket.org/[org]/[repo].git']
                ]
            ]


        echo 'Some build steps'

}


Change Log

2.0.0 (2019-06-25)

Full Changelog

Implemented enhancements:

  • Added pull request support for Bitbucket Server - Added pull request support for Mercurial on Bitbucket Cloud

Closed issues:

  • Issue #44 Branch expression matching before triggering the build: expecting fix for Bitbucket Server bug
  • Issue #37 Jenkins build triggered from push event with Mercurial instead of git enhancement

Merged pull requests: 

  • #49 Add warnings
  • #48 [Enhancement] Add pull request support for Bitbucket Server and Mercurial on Bitbucket Cloud

1.6.4 (2019-06-19)

Full Changelog

...