Код: Выделить всё
class Scratch {
public static void main(String[] args) {
String repoName = "https://github.somedomain.co/AppPipelines/some-project.git";
String username = "username";
String personalAccessToken = "some_personal_access_token";
String repoUrl = "https://github.somedomain.co/AppPipelines/some_repo";
String cloneDirectoryPath = "/Users/username/DSS/1223";
try {
// Create credentials provider with username and token
UsernamePasswordCredentialsProvider credentialsProvider =
new UsernamePasswordCredentialsProvider("token", personalAccessToken);
Git.cloneRepository()
.setURI(repoUrl)
.setDirectory(new File(cloneDirectoryPath))
.setBranch("main")
.setCredentialsProvider(credentialsProvider)
.call();
} catch (GitAPIException e) {
System.err.println("Error cloning repository: " + e.getMessage());
e.printStackTrace();
}
}
}
< /code>
Когда я пытаюсь запустить этот код, я получаю это исключение: < /p>
Error cloning repository: git@github.bamtech.co:AppPipelines/nexus-rm: remote hung up unexpectedly
org.eclipse.jgit.api.errors.TransportException: git@github.bamtech.co:AppPipelines/nexus-rm: remote hung up unexpectedly
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:319)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:189)
at Scratch.main(scratch_1.java:27)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.bamtech.co:AppPipelines/nexus-rm: remote hung up unexpectedly
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:317)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:152)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:153)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1458)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
... 3 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jgit.transport.SshSessionFactory.getSession(org.eclipse.jgit.transport.URIish, org.eclipse.jgit.transport.CredentialsProvider, org.eclipse.jgit.util.FS, int)" because "this.sch" is null
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:285)
... 8 more
< /code>
Вот плагины Gradle и зависимости: < /p>
plugins {
id 'org.springframework.boot' version '3.4.1'
id 'io.spring.dependency-management' version '1.1.0'
id 'java'
id 'jacoco'
id 'com.diffplug.spotless' version '6.20.0'
}
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${swaggerVersion}"
testImplementation "org.springframework.boot:spring-boot-starter-test"
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
implementation "org.springframework.boot:spring-boot-starter-validation"
implementation "org.eclipse.jgit:org.eclipse.jgit:${eclipseJgitVersion}"
implementation "com.google.code.gson:gson:${gsonVersion}"
implementation platform("software.amazon.awssdk:bom:${awsSdk}")
implementation 'software.amazon.awssdk:dynamodb'
implementation 'software.amazon.awssdk:dynamodb-enhanced'
implementation "com.github.derjust:spring-data-dynamodb:${springDataDynamoDB}"
implementation "com.amazonaws:aws-java-sdk-sts:${awsSdk1Sts}"
implementation "com.datadoghq:datadog-api-client:${ddClient}"
implementation 'software.amazon.awssdk:sts'
implementation 'software.amazon.awssdk:eks'
implementation "software.amazon.awssdk:batch:${awsSdk}"
implementation "software.amazon.awssdk:autoscaling:${awsSdk}"
implementation "software.amazon.awssdk:netty-nio-client:${awsSdk}"
implementation "software.amazon.awssdk:ec2:${awsSdk}"
implementation "software.amazon.awssdk:ecs:${awsSdk}"
implementation "com.datadoghq:java-dogstatsd-client:${dataDogStatSd}"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'io.micrometer:micrometer-registry-datadog:1.14.3'
implementation "org.springframework.security:spring-security-web:${springSecurityWebVersion}"
implementation "com.disneystreaming.nexus:common-java-libs:0.0.2"
}
Я не уверен, что мне здесь что-то не хватает. Это происходит только с определенным доменом, потому что я могу клонировать репозитории из других доменов без каких -либо проблем с соответствующими именами пользователей и токенов. Дайте мне знать, если в этом что -то не хватает. Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/794 ... tsession-b