【发布时间】:2018-03-13 16:19:48
【问题描述】:
使用 Jenkins Pipeline 我将存储库 URL 从 http 更改为 ssh git 访问。 这样做之后,这项工作就不再工作了(在此之前一切正常)。
在日志下方:
:xxxxxx:checkUpdateNeeded
Running [git, remote, update] produced an error: [Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin]
:xxxxxx:checkUpdateNeeded FAILED
:release FAILED
Release process failed, reverting back any changes made by Release Plugin.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkUpdateNeeded'.
> Failed to run [git remote update] - [Fetching origin
][Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin
]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
SSH RSA 密钥工作正常,因为: - 我在我们的 Bitbucket 服务器上正确配置,以便在该 repo 上读/写 - 我将密钥添加到 ssh-agent - 我可以直接从执行 jenkins 作业的服务器克隆和提交。
这是 gradle 构建文件部分:
....
release {
versionPropertyFile="${rootDir}/gradle.properties"
failOnCommitNeeded=false
git{
requireBranch="releases/.*|master"
}
tagTemplate = 'T-'+new Date().format('yy.MM')+'-${version}'
}
task publishRelease(type: GradleBuild) {
tasks = ['publishMavenJavaPublicationToReleaseRepository']
startParameter.projectProperties = [nexusUser: nexusUser, nexusPassword: nexusPassword]
}
....
【问题讨论】:
-
而 gradle 在 jenkins 中是由同一个用户执行的?
标签: git jenkins ssh gradle-release-plugin