3

我正在尝试使用 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
4

1 回答 1

1

我设法解决了这个问题。这个问题根本与插件无关,而是 git 本身如何工作。

您要么必须对凭据使用全局配置,要么必须使用本地配置

请参阅https://git-scm.com/docs/gitcredentials。我使用了本地版本,它工作得很好。

于 2016-03-16T01:58:50.257 回答