【发布时间】:2022-11-24 14:53:47
【问题描述】:
我有一个 Jenkins 管道作业来发布。它使用 Jenkin 的 Github 插件来签出项目并进行构建。
我的简化 DSL 是:
multibranchPipelineJob('Release') {
...
branchSources {
branchSource {
source {
github {
id('AAA')
repoOwner('BBB')
repository('CCC')
credentialsId('github-credentials')
repositoryUrl('https://github.com/BBB/CCC')
configuredByUrl(false)
}
}
...
}
}
...
}
我简化的“Jenkinsfile”就像:
pipeline {
agent any
stages {
stage('Build & Release') {
steps {
sh "./gradlew clean build release"
}
}
}
}
但是,当它尝试执行 release 任务时,它会失败并出现以下异常。
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/BBB/CCC.git: Authentication is required but no CredentialsProvider has been registered
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:531)
at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:434)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:127)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1335)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:137)
我的理解是,当 release 任务运行时,它会尝试使用 SSH 连接到 Github,但我没有设置一个,因为我们不想在 Github 上为 Jenkins 维护一个“用户”。如果不在 Github 上设置 SSH 密钥,我该如何解决这个问题?
【问题讨论】:
标签: github jenkins gradle release