How to use the bitbucket/internal/model/page-state.getPullRequest function in bitbucket

To help you get started, we’ve selected a few bitbucket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ParameterizedBuilds / parameterized-builds / src / main / resources / scripts / jenkins / pb-pr-trigger.js View on Github external
$(".parameterized-build-pullrequest").click(function() {
        var prJSON = require('bitbucket/internal/model/page-state').getPullRequest().toJSON();
        var branch = prJSON.fromRef.id;
        var commit = prJSON.fromRef.latestCommit;
        var prDest = prJSON.toRef.displayId;

        var resourceUrl = getResourceUrl("getJobs") + "?branch=" + encodeURIComponent(branch) + "&commit=" + commit + "&prdestination=" + encodeURIComponent(prDest) + "&prid=" + prJSON.id;

        return $.when(getJobs(resourceUrl)).then(function( jobs ) {
            allJobs = jobs
            if (jobs.length == 1){
                if (jobs[0].buildParameters.length == 0){
                    var splitBranch = branch.split("/")
                    splitBranch.splice(0, 2) //remove ref/heads or ref/tags
                    var branchName = splitBranch.join("%2F")
                    var buildUrl = getResourceUrl("triggerBuild/0/" + encodeURIComponent(branchName));
                    triggerBuild(buildUrl);
                    return false;

bitbucket

Bitbucket API client for Browser and Node.js

MIT
Latest version published 6 months ago

Package Health Score

64 / 100
Full package analysis