Reputation: 333
I need to use the maven-scm-plugin to export/checkout (the default branch of) a repository on github. I can get this working if I hard-code the username/password somewhere, but I can't get it to use ssh keys or the local filesystem password manager.
On the command prompt, I can do "git clone [email protected]:org/repo" or "git clone https://github.com/org/repo", and it will complete without my having to manually re-enter username/password details.
In my plugin, I can have the connectionUrl be scm:git:https://github.com/org/repo" and I can pass "-Dusername=foo -Dpassword=bar". But, then somewhere I have to have the username/password (foo/bar) in plain text somewhere.
I've seen advice for putting it in setting.xml, passing them as args, and having them in the pom file themselves. And I find evidence that ssh connections are supported. But, I can't find actual use of an ssh connection, or an https connection where you don't have the password in plain text somewhere. Any advice?
I got the following to work (if I pass -Dusername= -Dpassword=):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>checkout</goal>
</goals>
<id>perform-export</id>
<configuration>
<!-- Would be happy to get rid of provider -->
<providerImplementations>
<git>jgit</git>
</providerImplementations>
<!--
Want to use ssh, but cannot
<connectionUrl>scm:git:ssh://github.com/org/repo</connectionUrl>
-->
<connectionUrl>scm:git:https://github.com/org/repo</connectionUrl>
<exportDirectory>target</exportDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-jgit</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
Upvotes: 1
Views: 1904
Reputation: 341
You can put the password on your ~/.netrc
file:
machine github.com login john.smith password mypass
Upvotes: 0