Gradle uploadArchives via scp prompts for password muliple times

1.1k views Asked by At

I am trying out Gradle and am trying to upload jars to my Nexus repo using Wagon SCP as described in the Gradle user guide. I have taken the build file as specified in the user guide:

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")
        }
    }
}

(Of course with the exception that the URL and credentials are adapted to my repo.)

Now, when running gradle uploadArchives, the build freezes after a while. I cancelled the build and restarted it with info logging turned on and found that the script is prompting me for password:

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:: 

Apparently, the password configured in the build script is ignored.

Anyway, I entered the password and then got prompted some more times, where I obeyed and re-entered the password.

Finally, the build completed sucessfully.

Afterwards I checked my repo and the artifact had been uploaded successfully.

So, uploading jars to a repo works.

However, that the gradle prompts me for password does not work for me, since I planned to use this in a automated build process with Jenkins.

NOW TO MY QUESTION: Does anyone know if there is a way to turn this password prompting off?

1

There are 1 answers

0
user2959589 On

I don't know why it's prompting you for the password. That may be something to fix in a newer version of wagon. I do know that you can use this to avoid the need for a password:

repository(url: 'scp://example.com/var/repos') {
            authentication(userName: "me", privateKey: "/home/me/.ssh/id_rsa")
        }