首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何与使用ssh代理的maven进行git克隆?

如何与使用ssh代理的maven进行git克隆?
EN

Stack Overflow用户
提问于 2015-10-14 10:10:14
回答 1查看 2.6K关注 0票数 2

我想用maven克隆一个存储库,并且身份验证必须使用现有的ssh代理。

我目前的插件配置:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-scm-plugin</artifactId>
    <version>1.9.4</version>
    <configuration>
        <providerImplementations>
                <git>jgit</git>
        </providerImplementations>
    </configuration>
    <dependencies>
        <dependency>
                <groupId>org.apache.maven.scm</groupId>
                <artifactId>maven-scm-provider-jgit</artifactId>
                <version>1.9.4</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <id>clone-github-wiki</id>
            <goals>
                <goal>checkout</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <checkoutDirectory>${project.basedir}/target/github-wiki</checkoutDirectory>
                <connectionType>connection</connectionType>
                <connectionUrl>scm:git:git@github.com:xyz/abc.wiki.git</connectionUrl>
            </configuration>
        </execution>
    </executions>
</plugin>

身份验证失败:

代码语言:javascript
复制
[INFO] --- maven-scm-plugin:1.9.4:checkout (clone-github-wiki) @ xyz-doc ---
[INFO] Change the default 'git' provider implementation to 'jgit'.
[INFO] Removing /home/jenkins/abc/doc/target/github-wiki
[INFO] cloning [master] to /home/jenkins/abc/doc/target/github-wiki
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.490 s
[INFO] Finished at: 2015-10-14T11:45:40+02:00
[INFO] Final Memory: 15M/241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.9.4:checkout (clone-github-wiki) on project xyz-doc: Cannot run checkout command : Exception while executing SCM command. JGit checkout failure! git@github.com:abc/xyz.wiki.git: Auth fail -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-14 11:03:40

可以使用exec插件来调用git命令。在这种情况下,ssh代理被使用。

代码语言:javascript
复制
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.3.2</version>
    <executions>
        <execution>
            <id>github-wiki-clone</id>
            <goals>
                <goal>exec</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <executable>git</executable>
                <arguments>
                    <argument>clone</argument>
                    <argument>-b</argument>
                    <argument>master</argument>
                    <argument>git@github.com:abc/xyz.wiki.git</argument>
                    <argument>target/github-wiki</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33122525

复制
相关文章

相似问题

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