Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.chimerapps:bitbucketcloud-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.chimerapps:bitbucketcloud-api

Java library for interfacing with the bitbucket cloud api

  • 0.1.2
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Bitbucket Cloud API

Java Library to acces the Bitbucket Cloud API.
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories

Supported API Calls

  • Get User
  • Get Repositories
  • Get Default Users
  • Create Pull Request

Authentication

Username

This is the name chosen when you created your account. (It can be found in the Bitbucket Settings under Account Settings)

App Token

This is a token you need to generate in your Bitbucket Settings. Go to App Passwords (under Acces Management). You can create a new App Password. This will be used instead of your 2 Step Verification.

settings

settings-config

The best option to save your Username and App Token is to save them in your System Environment (for Mac You can use EnvPane or just set them with commandline.)

Get User

Documentation

final Response<BitbucketUser> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                             .getUser()
                             .execute();

Get Repositories

Documentation

final Response<PagedList<BitbucketRepository>> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                            .getRepositories(user,PropertyCompare.eq("name", repoSlug))
                            .execute();

Get Default Users

Documentation

final Response<PagedList<BitbucketRepository>> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                            .getDefaultReviewers(user, repoSlug)
                            .execute();

Create Pull Request

Documentation

Without reviewers:

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, null);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();

With reviewers (your own username may not be included):

final Response<PagedList<DefaultReviewer>> responseDefaultReviewers = mBitbucket.getApi()
                .getDefaultReviewers(user, repoSlug)
                .execute();
                
final PagedList<DefaultReviewer> defaultReviewers = responseDefaultReviewers.body();

final List<DefaultReviewer> filteredList = defaultReviewers.getValues()
                .stream()
                .filter(r -> !r.getUsername().equals(USERNAME))
                .collect(Collectors.toList());

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, filteredList);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();

With hardcoded reviewer:

final List<DefaultReviewer> reviewers = new ArrayList();
reviewers.add(new DefaultReviewer("username-of-the-reviewer"));

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, reviewers);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();

FAQs

Package last updated on 09 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc