我需要使用maven-scm-plugin导出/签出github上的存储库(默认分支)。如果我在某个地方硬编码用户名/密码,我可以让它工作,但我不能让它使用ssh密钥或本地文件系统密码管理器。
在命令提示符下,我可以输入"git clone git@github.com:org/repo“或"git clone https://github.com/org/repo",它将完成,而无需我手动重新输入用户名/密码详细信息。
在我的插件中,我可以让connectionUrl为scm:git:https://github.com/org/repo“,我可以传递"-Dusername=foo -Dpassword=bar”。但是,在某个地方,我必须在某个地方拥有纯文本形式的用户名/密码(foo/bar)。
我已经看到了对putting it in setting.xml、passing them as args和having them in the pom file themselves的建议。我找到了evidence that ssh connections are supported。但是,我找不到ssh连接的实际用途,也找不到没有明文密码的https连接。有什么建议吗?
我得到了以下代码(如果我通过了-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>
发布于 2015-06-05 20:20:41
您可以将密码放在~/.netrc文件中:
machine github.com login john.smith password mypass
https://stackoverflow.com/questions/30653079
复制相似问题