bitbucket - Is there a way to checkout code from Bitbucker server (stash) from within Java code -


we maintaining javascript code within bitbucket. want able checkout javascript code bitbucket , able access .js file within our java application.

is there way checkout code using java. there library available can us.

for example, when want checkout git repository git client, execute command git clone https://bitbucketserverhost/project/repo.git create folder repo name in current directory , checkout source files in folder.

is there way git clone within java. want java code read latest javascript files committed developers within bitbucket, access file able read contents , compare other file.

i ended using eclipse's jgit library checking out code bitbucket in java. added below maven dependency.

<dependency>     <groupid>org.eclipse.jgit</groupid>     <artifactid>org.eclipse.jgit</artifactid>     <version>4.8.0.201706111038-r</version> </dependency>    

below line of code can used code can used create clone.

import org.eclipse.jgit.api.git; import org.eclipse.jgit.api.clonecommand; import org.eclipse.jgit.api.errors.gitapiexception; import java.io.file;  class test {     public static void main(string[] args){         clonecommand clone = git.clonerepository().seturi(uri).setdirectory(new file(checkoutdir));         try {             clone.call();         }          catch (gitapiexception e) {             system.err.println(e.getmessage());             e.printstacktrace(system.err);         }     } } 

where uri git uri of repository use in git clone command. important note have not specified credentials anywhere in code because repository public. if repo trying clone, not public, need add more code.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -