Reputation: 3632
I want to clone a repository with maven and the authentication must use an existing ssh-agent.
My current plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<providerImplementations>
<git>jgit</git>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-jgit</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>clone-github-wiki</id>
<goals>
<goal>checkout</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<checkoutDirectory>${project.basedir}/target/github-wiki</checkoutDirectory>
<connectionType>connection</connectionType>
<connectionUrl>scm:git:[email protected]:xyz/abc.wiki.git</connectionUrl>
</configuration>
</execution>
</executions>
</plugin>
Authentication is failing:
[INFO] --- maven-scm-plugin:1.9.4:checkout (clone-github-wiki) @ xyz-doc ---
[INFO] Change the default 'git' provider implementation to 'jgit'.
[INFO] Removing /home/jenkins/abc/doc/target/github-wiki
[INFO] cloning [master] to /home/jenkins/abc/doc/target/github-wiki
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.490 s
[INFO] Finished at: 2015-10-14T11:45:40+02:00
[INFO] Final Memory: 15M/241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.9.4:checkout (clone-github-wiki) on project xyz-doc: Cannot run checkout command : Exception while executing SCM command. JGit checkout failure! [email protected]:abc/xyz.wiki.git: Auth fail -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
Upvotes: 3
Views: 3252
Reputation: 3632
The exec plugin can be used to invoke the git command. In that case the ssh-agent is utilized.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>github-wiki-clone</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>git</executable>
<arguments>
<argument>clone</argument>
<argument>-b</argument>
<argument>master</argument>
<argument>[email protected]:abc/xyz.wiki.git</argument>
<argument>target/github-wiki</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 3