我正在尝试使用Gradle,并尝试使用Wagon SCP将罐子上传到我的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::
显然,忽略构建脚本中配置的密码。
无论如何,我输入了密码,然后又多次提示,我服从并重新输入密码。
最后,构建成功完成。
之后我检查了我的仓库并且工件已成功上传。
因此,将罐子上传到回购品中。
但是,gradle提示我输入密码对我不起作用,因为我计划在Jenkins的自动构建过程中使用它。
现在我的问题: 有没有人知道是否有办法将此密码提示关闭?
答案 0 :(得分:0)
我不知道为什么它会提示您输入密码。这可能是在较新版本的旅行车中修复的东西。我知道您可以使用它来避免使用密码:
repository(url: 'scp://example.com/var/repos') {
authentication(userName: "me", privateKey: "/home/me/.ssh/id_rsa")
}