Need help cloning repos from within a plugin

Hi,

I’m looking to temporarily clone repos from within my BitBucket plugin and then produce stats based on the current version of a given branch. I have had some moderate success using JGit but now I’m takling different protocols and authentication and getting increasingly confused (plus JGit can’t do shadow cloning).

I have seen a number of threads here which mention

GitScmCommandBuilder 

and

GitCommandBuilderFactory 

however despite finding them in the BB sources, I can’t get Intellij to resolve them. Am I missing a dependency somewhere ? There are also a few mentions of the YACC plugin which apparently does something similar but unfortunately its source code is not longer publically available :frowning: .

Any ideas?

Cheers!

OK so I figured it out but cloning isn’t working. The following:

builderFactory.builder().clone().normal()
            .origin(repository)
            .branch("master")
            .directory(cloneDir)
            .build()
            .call();

yields:

[INFO] org.eclipse.jgit.api.errors.TransportException: ssh://git@localhost:7999/project_1/rep_1.git: remote hung up unexpectedly
[INFO]  at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:222)
[INFO]  at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:302)
[INFO]  at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:178)
[INFO]  at com.myplugin.scheduler.impl.ScannerJobRunnerImpl.cloneRepo(ScannerJobRunnerImpl.java:104)
[INFO]  at com.myplugin.scheduler.impl.ScannerJobRunnerImpl.process(ScannerJobRunnerImpl.java:77)
[INFO]  at com.myplugin.scheduler.impl.ScannerJobRunnerImpl.runJob(ScannerJobRunnerImpl.java:57)
[INFO]  at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134)
[INFO]  at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:106)
[INFO]  at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:90)
[INFO]  at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:435)
[INFO]  at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeLocalJob(CaesiumSchedulerService.java:402)
[INFO]  at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:380)
[INFO]  at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
[INFO]  at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
[INFO]  at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
[INFO]  at java.lang.Thread.run(Thread.java:748)
[INFO] Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@localhost:7999/project_1/rep_1.git: remote hung up unexpectedly
[INFO]  at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:270)
[INFO]  at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:144)
[INFO]  at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:105)
[INFO]  at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:91)
[INFO]  at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1260)
[INFO]  at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:211)
[INFO]  ... 15 more
[INFO] Caused by: java.lang.NullPointerException
[INFO]  at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
[INFO]  at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:254)
[INFO]  ... 20 more

Any ideas?