No description, website, or topics provided.
Clone or download
Christian Del Monte
Latest commit afcf4e7 Jan 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Develop (#4) Jan 2, 2019
.gitignore first commit Dec 4, 2018
Jenkinsfile Add Jenkinsfile Dec 18, 2018
MIT-LICENSE.txt first commit Dec 4, 2018
README.md Develop (#4) Jan 2, 2019
pom.xml [maven-release-plugin] prepare for next development iteration Jan 2, 2019

README.md

Bitbucket Push and Pull Request Plugin

Plugin for Jenkins v2.138.2 or later, that trigger 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:

  • support of pull requests (thanks Sazo)
  • usage of Gson instead of net.sf.json.JSONObject (blacklisted starting from Jenkins 2.102+)
  • Introduction of Models and security improvements

Bitbucket Push and Pull Request supports the Bitbucket rest api v2.x+ and later.

For infos about the plugin's configuration please visit the webpage https://plugins.jenkins.io/bitbucket-push-and-pull-request

Why another BitBucket plugin?

The main reasons why we should have IMHO a new bitbucket plugin are not only related to the missing pull request functionality. In particular:

Pipeline script

Example of pipeline code for building on pull-request create event. It merge from source to target in the PR.

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'

}