【发布时间】:2015-06-04 20:01:37
【问题描述】:
我需要使用 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>
【问题讨论】:
标签: git ssh maven-scm-plugin