1

我正在尝试使用 Gradle 并尝试使用 Wagon SCP 将 jar 上传到我的 Nexus 存储库,如 Gradle 用户指南中所述。我已按照用户指南中的说明获取构建文件:

configurations {
    deployerJars
}

repositories {
    mavenCentral()
}

dependencies {
    deployerJars "org.apache.maven.wagon:wagon-ssh:1.0-beta-2"
}

uploadArchives {
    repositories.mavenDeployer {
        name = 'sshDeployer' // optional
        configuration = configurations.deployerJars
        repository(url: "scp://repos.mycompany.com/releases") {
            authentication(userName: "me", password: "myPassword")
        }
    }
}

(当然,除了 URL 和凭据适用于我的存储库。)

现在,当运行gradle uploadArchives时,构建会在一段时间后冻结。我取消了构建并在打开信息日志的情况下重新启动它,发现脚本提示我输入密码:

gradle -i uploadArchives
Starting Build
Settings evaluated using empty settings file.
Projects loaded. Root project using build file '/Users/developer/Slask/ex24/build.gradle'.
Included projects: [root project 'ex24']
Evaluating root project 'ex24' using build file '/Users/developer/Slask/ex24/build.gradle'.
All projects evaluated.
Selected primary task 'uploadArchives'
Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':jar', task ':uploadArchives']
:compileJava
Executing task ':compileJava' due to:
No history is available for task ':compileJava'.
[ant:javac] Compiling 1 source file to /Users/developer/Slask/ex24/build/classes/main
[ant:javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[ant:javac] 1 warning
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:classes
Skipping task ':classes' as it has no actions.
:jar
Executing task ':jar' due to:
No history is available for task ':jar'.
:uploadArchives
Task ':uploadArchives' has not declared any outputs, assuming that it is out-of-date.
Publishing configuration: configuration ':archives'
:: loading settings :: url = jar:file:/usr/local/Cellar/gradle/1.0-milestone-7/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
Publishing to Resolver org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer@53c0f47a
[ant:null] Deploying to scp://192.168.0.100/mynexusrepo
[INFO] Retrieving previous build number from remote
Password:: 

显然,构建脚本中配置的密码被忽略了。

无论如何,我输入了密码,然后又被提示了几次,我服从并重新输入了密码。

最后,构建成功完成。

之后我检查了我的 repo,工件已成功上传。

因此,将 jars 上传到 repo 是可行的。

但是,gradle 提示我输入密码对我不起作用,因为我计划在 Jenkins 的自动构建过程中使用它。

现在我的问题:有谁知道是否有办法关闭此密码提示?

4

1 回答 1

0

我不知道为什么它会提示您输入密码。这可能是在较新版本的旅行车中要解决的问题。我知道您可以使用它来避免需要密码:

repository(url: 'scp://example.com/var/repos') {
            authentication(userName: "me", privateKey: "/home/me/.ssh/id_rsa")
        }
于 2015-10-01T23:33:16.663 回答