我使用Jenkins Pipelines构建我的包并将它们传递给Artifactory。我试图通过Gradle Release Plugin将它与Gradle一起使用,但它有问题。
我正在启动一个ssh-agent,以便Gradle有权推送Git存储库:
sshagent([git_credential]) {
sh "./gradlew clean release unSnapshotVersion -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${release_version} -Prelease.newVersion=${development_version}"
}
问题是Gradle似乎异步运行,ssh-agent在Gradle执行结束之前停止。请参阅上面的Jenkins日志:
[Pipeline] sshagent
[ssh-agent] Using credentials git
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] Java/JNR ssh-agent
[ssh-agent] Registered BouncyCastle on the remote agent
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[Release - MyModule] Running shell script
+ ./gradlew clean release unSnapshotVersion -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=1.1.0 -Prelease.newVersion=1.2.0-SNAPSHOT
:clean
:release
:Release - MyModule:createScmAdapter
:Release - MyModule:initScmAdapter
:Release - MyModule:checkCommitNeeded
[ssh-agent] Stopped.
:Release - MyModule:checkUpdateNeeded
Running [git, remote, update] produced an error: [fatal: could not read Username for 'https://bitbucket.org': No such device or address
error: Impossible de récupérer origin]
:Release - MyModule:checkUpdateNeeded FAILED
:release FAILED
Release process failed, reverting back any changes made by Release Plugin.
是否可以强制Gradle同步运行?
由于
答案 0 :(得分:0)
日志误导了我,ssh-agent正在退出,因为Gradle无法访问GIT存储库。事实上,正在使用https克隆一个Bitbucket repo,需要用户+ pwd。 使用SSH克隆相同的repo时,ssh-agent提供证书,Gradle能够与Bitbucket通信。