使用Gradle Release Plugin进行SSH Git访问 [英] SSH Git access using Gradle Release Plugin

查看:178
本文介绍了使用Gradle Release Plugin进行SSH Git访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Jenkins Pipeline,我将Repository URL从http更改为ssh git access. 这样做之后,该工作不再起作用(在所有工作均正常之前).

Using Jenkins Pipeline I changed the Repository URL from http to ssh git access. After doing that the job is not working anymore (before that all worked correctly).

在日志下方:

: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服务器上配置正确,以便在该存储库上进行读取/写入 -我将密钥添加到ssh-agent -我可以直接从执行jenkins作业的服务器上克隆并提交.

The SSH RSA Key is correctly working because: - I configured correctly on our Bitbucket server in order to Read/Write on that repo - I added the key into ssh-agent - I can clone and commit directly from the server where the jenkins job is executed.

这是gradle构建文件部分:

This is the gradle build file section:

....
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]
}
....

推荐答案

我可以直接从执行jenkins作业的服务器上克隆并提交.

I can clone and commit directly from the server where the jenkins job is executed.

然后詹金斯也应该提供:

Then Jenkins should too, provided:

  • 由同一用户执行
  • 并且SSH密钥是默认的〜/.ssh/id_rsa.

如果不满足这两个条件中的任何一个,则需要使用 Jenkins SSH凭据插件.

If any of those two conditions is not met, you need to specify the exact path of the private key, using the Jenkins SSH Credentials Plugin.

这篇关于使用Gradle Release Plugin进行SSH Git访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆