Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function connect (conf) {
if (conf["bitbucket.secret"] && conf["bitbucket.key"]) {
var oauth = {
"consumer_key": conf["bitbucket.key"],
"consumer_secret": conf["bitbucket.secret"]
};
return checkOAuth(oauth).then(null, createOAuth);
} else {
// No token found: create new one
return createOAuth();
}
}
function connect (conf) {
if (conf["bitbucket.secret"] && conf["bitbucket.key"]) {
var oauth = {
"consumer_key": conf["bitbucket.key"],
"consumer_secret": conf["bitbucket.secret"]
};
return checkOAuth(oauth).then(null, createOAuth);
} else {
// No token found: create new one
return createOAuth();
}
}
function connect (conf) {
if (conf["bitbucket.secret"] && conf["bitbucket.key"]) {
var oauth = {
"consumer_key": conf["bitbucket.key"],
"consumer_secret": conf["bitbucket.secret"]
};
return checkOAuth(oauth).then(null, createOAuth);
} else {
// No token found: create new one
return createOAuth();
}
}
constructor(@inject(Types.ArgumentsProvider) argumentsProvider: ArgumentsProvider) {
this.cache = new InMemoryCache();
// const clientOptions = {
// baseUrl: 'https://api.bitbucket.org/2.0',
// headers: {},
// options: {
// timeout: 10,
// },
// };
this.client = new Bitbucket();
let auth: Bitbucket.Auth;
if (argumentsProvider.auth) {
auth = { type: 'token', token: argumentsProvider.auth };
this.client.authenticate(auth);
}
}
deferred.resolve(view);
}).fail(function() {
console.log('error while asynchronously loading asciidoc-view resources');
return deferred.reject();
});
return deferred;
}
return false;
}
});
require('bitbucket/feature/files/file-handlers').register({
weight: 900,
handle: function(options) {
return require('asciidoc/asciidoc-handler').apply(this, arguments);
}
});
$(".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;