Maven - 将代码发布到 GitHub 时出错(推送后挂起) [英] Maven - Error Releasing Code to GitHub (Hangs After Push)

查看:17
本文介绍了Maven - 将代码发布到 GitHub 时出错(推送后挂起)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 mvn release:prepare 目标,但它在推送后挂起.知道我可能做错了什么吗?

[INFO] [INFO] ------------------------------------------------------------------------[信息] [信息] 构建成功[信息] [信息] -------------------------------------------------------------------------[INFO] [INFO] 总时间:8 秒[INFO] [INFO] 完成时间:2010 年 7 月 13 日星期二 23:54:59 PDT[INFO] [INFO] 最终内存:55M/294M[信息] [信息] -------------------------------------------------------------------------[信息] 正在检查修改后的 POM...[信息] 执行:cmd.exe/X/C "git add -- pom.xml"[信息] 工作目录:C:development	aylormy-app[信息] 正在执行:cmd.exe/X/C "git status"[信息] 工作目录:C:development	aylormy-app[信息] 执行:cmd.exe/X/C "git commit --verbose -F C:UsersTAYLOR~1AppDataLocalTempmaven-scm-1932347225.commit pom.xml"[信息] 工作目录:C:development	aylormy-app[信息] 正在执行:cmd.exe/X/C "git symbols-ref HEAD"[信息] 工作目录:C:development	aylormy-app[信息] 执行: cmd.exe/X/C "git push git@github.com:tleese22/my-app.git master:master"[信息] 工作目录:C:development	aylormy-app>>>>挂在这里<<<<

下面是我的 pom.xml 的 SCM 部分:

<connection>scm:git:git://github.com/tleese22/my-app.git</connection><developerConnection>scm:git:git@github.com:tleese22/my-app.git</developerConnection><url>http://github.com/tleese22/my-app</url></scm>...<插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.0</version></插件>

下面是我的.git/config:

[核心]存储库格式版本 = 0文件模式 = 真logallrefupdates = 真裸 = 假[分支大师"]远程 = 原点合并 = refs/heads/master[远程起源"]url = git@github.com:tleese22/my-app.gitfetch = +refs/heads/*:refs/remotes/origin/*pushurl = git@github.com:tleese22/my-app.git

这是git show origin的结果:

$ git remote show origin输入密钥/c/Users/Taylor Leese/.ssh/id_rsa"的密码:* 远程来源获取网址:git@github.com:tleese22/my-app.git推送地址:git@github.com:tleese22/my-app.gitHEAD 分支:master远程分支:gh-pages new(下一次获取将存储在遥控器/原点中)master new(下一次获取将存储在 remotes/origin 中)为git pull"配置的本地分支:master 与远程 master 合并为git push"配置的本地引用:master 推送到 master(最新)$ git 状态# 在分支主无需提交(工作目录干净)

解决方案

考虑git builtin-push.c,这意味着不知何故,没有为 maven 脚本使用的本地 Git 存储库定义远程.

 static int do_push(const char *repo, int flags){国际我,错误;struct remote *remote = remote_get(repo);const char **url;int url_nr;如果(!远程){如果(回购)die("坏仓库'%s'", repo);die("没有配置要推送到的目的地.");}

如本博客所示发布,maven 配置不是全部.

~/foo/mikeci-archetype-springmvc-webapp$ git remote add origin git@github.com:amleggett/mikeci-archetype-springmvc-webapp.git

在指定maven scm参数之前,仍然需要远程添加:

<块引用>

更新 POM

为了让 Maven 有效运行,您应该始终确保在 POM 文件中包含项目 VCS 信息.
现在我们已经将原型添加到 Git 存储库中,我们可以包含适当的 <scm> 配置:

 <连接>scm:git:ssh://github.com/amleggett/${artifactId}.git</连接><developerConnection>scm:git:ssh://git@github.com/amleggett/${artifactId}.git</developerConnection><网址>http://github.com/amleggett/${artifactId}</scm>

同一篇博文补充说:

<块引用>

了解 的每个子元素的含义很重要.

  • 元素定义了一个只读 url 和
  • 元素是一个读写 url.

对于这两个元素,url 必须遵守以下约定:

 scm::

<块引用>

  • 最后,<url> 元素内容应该指向一个可浏览的位置,对我来说这是 GitHub 存储库主页.请注意,在所有情况下,我都使用了一个内插值,即我的项目 artifactId.

一个方便的提示是,您可以使用 maven-scm-plugin 验证此配置.
该插件通过为已配置的 VCS 提供一组命令映射,提供对常见 VCS 命令的供应商"独立访问.验证目标应确认一切正常:

~/foo/mikeci-archetype-springmvc-webapp$ mvn scm:validate[信息] 准备 scm:validate[信息] 项目不需要目标 - 跳过[信息] [scm:validate {execution: default-cli}][INFO] connectionUrl scm 连接字符串有效.[INFO] project.scm.connection scm 连接字符串有效.[INFO] project.scm.developerConnection scm 连接字符串有效.[信息] --------------------------------------------------------------[信息] 构建成功

I'm attempting to run the mvn release:prepare goal and it's hanging after the push. Any idea what I could be doing wrong?

[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESSFUL
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 8 seconds
[INFO] [INFO] Finished at: Tue Jul 13 23:54:59 PDT 2010
[INFO] [INFO] Final Memory: 55M/294M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:development	aylormy-app
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:development	aylormy-app
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:UsersTAYLOR~1AppDataLocalTempmaven-scm-1932347225.commit pom.xml"
[INFO] Working directory: C:development	aylormy-app
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:development	aylormy-app
[INFO] Executing: cmd.exe /X /C "git push git@github.com:tleese22/my-app.git master:master"
[INFO] Working directory: C:development	aylormy-app
>>>> hangs here <<<<

Below is the SCM section of my pom.xml:

<scm>
    <connection>scm:git:git://github.com/tleese22/my-app.git</connection>
    <developerConnection>scm:git:git@github.com:tleese22/my-app.git</developerConnection>
    <url>http://github.com/tleese22/my-app</url>
</scm>

...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.0</version>
</plugin>

Below is my .git/config:

[core]
    repositoryformatversion = 0
    filemode = true
    logallrefupdates = true
    bare = false
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "origin"]
    url = git@github.com:tleese22/my-app.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    pushurl = git@github.com:tleese22/my-app.git

Here's the result of git show origin:

$ git remote show origin
Enter passphrase for key '/c/Users/Taylor Leese/.ssh/id_rsa':
* remote origin
  Fetch URL: git@github.com:tleese22/my-app.git
  Push  URL: git@github.com:tleese22/my-app.git
  HEAD branch: master
  Remote branches:
    gh-pages new (next fetch will store in remotes/origin)
    master   new (next fetch will store in remotes/origin)
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

$ git status
# On branch master
nothing to commit (working directory clean)

解决方案

Considering the source of git builtin-push.c, that means that somehow, no remote are defined for the local Git repo used by the maven script.

    static int do_push(const char *repo, int flags)
    {
        int i, errs;
        struct remote *remote = remote_get(repo);

        const char **url;
        int url_nr;


        if (!remote) {
            if (repo)
                die("bad repository '%s'", repo);
            die("No destination configured to push to.");
        }

As illustrated by this blog post, the maven config is not the all story.

~/foo/mikeci-archetype-springmvc-webapp$ git remote add origin git@github.com:amleggett/mikeci-archetype-springmvc-webapp.git

A remote add is still required, before specifying the maven scm parameters:

Updating the POM

For Maven to function effectively, you should always ensure that you include project VCS information in your POM file.
Now that we’ve added the archetype to a Git repository we can include the appropriate <scm> configuration:

  <scm>
   <connection>
   scm:git:ssh://github.com/amleggett/${artifactId}.git
   </connection>
   <developerConnection>
   scm:git:ssh://git@github.com/amleggett/${artifactId}.git
   </developerConnection>
   <url>
   http://github.com/amleggett/${artifactId}
   </url>
  </scm>

The same blog post adds:

It’s important to understand the meaning of each of the child elements of <scm>.

  • The <connection> element defines a read-only url and
  • the <developerConnection> element a read+write url.

For both of these elements the url must adhere to the following convention:

 scm:<scm implementation>:<scm implementation-specific path>

  • Finally, the <url> element content should point to a browsable location and for me this is the GitHub repository home page. Note that in all cases, I’m using an interpolated value which is my project artifactId.

One handy tip is that you can verify this configuration by using the maven-scm-plugin.
This plugin offers ‘vendor’ independent access to common VCS commands by offering a set of command mappings for the configured VCS. The validate goal should confirm all is well:

~/foo/mikeci-archetype-springmvc-webapp$ mvn scm:validate
[INFO] Preparing scm:validate
[INFO] No goals needed for project - skipping
[INFO] [scm:validate {execution: default-cli}]
[INFO] connectionUrl scm connection string is valid.
[INFO] project.scm.connection scm connection string is valid.
[INFO] project.scm.developerConnection scm connection string is valid.
[INFO] --------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

这篇关于Maven - 将代码发布到 GitHub 时出错(推送后挂起)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆