【问题标题】:Using the maven-scm-plugin with git without storing a password in plaintext将 maven-scm-plugin 与 git 一起使用,而不以明文形式存储密码
【发布时间】: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.xmlpassing them as argshaving 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


    【解决方案1】:

    您可以将密码放在您的~/.netrc 文件中:

    machine github.com login john.smith password mypass

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-19
      • 2013-02-19
      • 1970-01-01
      • 2021-03-15
      • 2013-10-27
      相关资源
      最近更新 更多