无法从 git 的 git post-update 钩子中获取依赖项。

huangapple go评论84阅读模式
英文:

Failed to get dependency from git on git post-update hook

问题

我有一个 Golang 项目,我想在服务器上构建它,就像我推送它一样。

post-update 钩子被触发,一切都很好,项目被检出到某个目录,但是,在尝试获取依赖项 (cd /go/src/kiyanov.com/app/go get) 之后,它失败并显示错误信息:

remote: fatal: Not a git repository: '.'
remote: package github.com/dgrijalva/jwt-go: exit status 128```

```remote # cd /go/src/github.com/lib/pq; git show-ref
remote: fatal: Not a git repository: '.'
remote: package github.com/lib/pq: exit status 128```

```remote: # cd /go/src/golang.org/x/oauth2; git show-ref
remote: fatal: Not a git repository: '.'
remote: package golang.org/x/oauth2: exit status 128```

gopath 已正确导出,并且已下载了包。
但是,在这些命令之后,go install 失败了。

在下一次推送之后,go install 在 post-update 钩子再次执行时正常工作。

我不知道为什么它不起作用。唯一的建议是它发生在 post-update 钩子内部,但我不确定。

<details>
<summary>英文:</summary>

I have a golang project and i want to build it on server as I push it

post-update hook is fired, everything nice, project is checked out to some directory, but, after it attempts to get dependency (`cd /go/src/kiyanov.com/app/` and `go get` ) it fails with an error

```remote # cd /go/src/github.com/dgrijalva/jwt-go; git show-ref
remote: fatal: Not a git repository: &#39;.&#39;
remote: package github.com/dgrijalva/jwt-go: exit status 128```

```remote # cd /go/src/github.com/lib/pq; git show-ref
remote: fatal: Not a git repository: &#39;.&#39;
remote: package github.com/lib/pq: exit status 128```

```remote: # cd /go/src/golang.org/x/oauth2; git show-ref
remote: fatal: Not a git repository: &#39;.&#39;
remote: package golang.org/x/oauth2: exit status 128```


gopath is exported properly, and packages are downloaded. 
but go install following after this commands are failed

go install works fine after the following push, once post-update make everything again in existing directory.

I don&#39;t have any ideas why it not works .The only suggestion cause it happens inside post-update hook, but i&#39;m not sure.

</details>


# 答案1
**得分**: 0

我的解决方案是安装Jenkins,将所有脚本移动到其中,并通过Jenkins从`post-update`脚本开始构建。

<details>
<summary>英文:</summary>

My solution was to install Jenkins, move all scripts to it, and initiate building with Jenkins from `post-update` script

</details>



huangapple
  • 本文由 发表于 2016年3月21日 20:00:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/36130459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定