我尝试使用gradle release插件发布,但每当插件使用GIT时,它都没有传递我的用户名和密码:
我将其调用为:
我正在使用:
C:\GradleReleaseTest>gradle --version
------------------------------------------------------------
Gradle 2.11
------------------------------------------------------------
Build time: 2016-02-08 07:59:16 UTC
Build number: none
Revision: 584db1c7c90bdd1de1d1c4c51271c665bfcba978
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b18)
OS: Windows 7 6.1 amd64
我的gradle版本配置如下:
release {
failOnCommitNeeded = true
failOnPublishNeeded = true
failOnSnapshotDependencies = true
failOnUnversionedFiles = true
failOnUpdateNeeded = true
revertOnFail = true
preCommitText = ''
preTagCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - pre tag commit: '
tagCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - creating tag : '
newVersionCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - new version commit: '
tagTemplate = '${version}'
// May decide to add additional custom tasks here
buildTasks = ['build']
scmAdapters = [
net.researchgate.release.GitAdapter
]
}
我得到的错误如下:
C:\GradleReleaseTest>gradle release -Prelease.releaseVersion=1
.0.0 -Prelease.newVersion=1.0.1-SNAPSHOT -Prelease.username=jvergara -Prelease.p
assword=thePassword
:release
:com.mycompany.gradletest:createScmAdapter
:com.mycompany.gradletest:initScmAdapter
:com.mycompany.gradletest:checkCommitNeeded
:com.mycompany.gradletest:checkUpdateNeeded
Running [git, remote, update] produced an error: [bash: /dev/tty: No such device
or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.mycompany.com': Invalid ar
gument
error: Could not fetch origin]
:com.mycompany.gradletest: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
][bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://git.mycompany.com': Invalid ar
gument
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
Total time: 5.912 secs
答案 0 :(得分:1)
我设法解决了这个问题。问题根本与插件无关,而是git本身如何工作。
您必须使用全局配置获取凭据,或者必须使用本地配置
见https://git-scm.com/docs/gitcredentials。我使用的是本地版本,它运行得很好。