首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将maven-scm-plugin与git一起使用,而不以明文形式存储密码

将maven-scm-plugin与git一起使用,而不以明文形式存储密码
EN

Stack Overflow用户
提问于 2015-06-05 04:01:37
回答 1查看 1.5K关注 0票数 0

我需要使用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=):

代码语言:javascript
复制
<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>

EN

回答 1

Stack Overflow用户

发布于 2015-06-05 20:20:41

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

machine github.com login john.smith password mypass

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30653079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档