Skip to content

Java Client Implementation to Bitbucket Cloud REST API v2.0

License

Notifications You must be signed in to change notification settings

Aliction/bitbucket-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bitbucket Client

This repository is build to work as a Java rest client for bitbucket cloud APIs V2

Add dependency

      <dependency>
        <groupId>com.aliction</groupId>
        <artifactId>bitbucket-client</artifactId>
        <version>0.2.0</version>
      </dependency>

Check versions from maven central Bitbucket-Client

Usage

First you need to create an instance of BitbucketV2API class which expects 3 String input parameter:

  • hostURL: your bitbucket api server url
  • username: your bitbucket user name
  • token: bitbucket API token

BitbucketV2API bitbucket = new BitbucketV2API("https://api.bitbucket.org", "my-user","9876234b92g3479cf2geiywrtg62834r");

This newly created bitbucket object will give you access to all the implemented APIs and their provided methods, for example:

  • To get list of all public repositories on bitbucket:

List<BitbucketRepository> userRepos = bitbucket.RepositoryAPI().getAllPublicRepositories();

  • To get the user object of the currently logged user:

BitbucketUser user = bitbucket.UserAPI().getLoggedUser();

  • To get list of teams the user has admin role to:

List<BitbucketTeam> teams = bitbucket.TeamAPI().getUserTeams(BitbucketRole.ADMIN);

JavaDoc

JavaDoc is coming soon HERE

Contribution

The library is published while still work in progress for adding more APIs and handling more functions, you're valuable contribution will help adding more features to the library, contribution can be and not limited to:

  • Opening issues towards the library for any missing functionality
  • Opening new PRs for adding new functionality that you want to make it available to the public and set you as a contributor to the library
  • Actively opening an issue if you found any bug or faced any issue while using the library
  • Opening new PRs for enhancing documentation, JavaDoc, or the README instructions
  • Opening issues for having any questions regarding the library usage
  • Any other contribution scenario that is not mentioned above

Troubleshooting

Sometimes if the your application has conflicting dependencies with other libraries, you may get exceptions while parsing json responses for MessageBodyReader Exceptions like below:

	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:208)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1071)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:850)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:784)
	at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:297)
	at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:91)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:365)
	at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:240)
	at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:88)
    ...

Adding the json media library can help solve this issue:

	  <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.29.1</version>
      </dependency>

License

This library is released for Aliction under Apache 2 License. Check License for more information.

Additonal Resources

Bitbucket Deprecating API V1 Announcement

Announcing Bitbucket API V2

Bitbucket API V2 Reference