英文:
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: '.'
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 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't have any ideas why it not works .The only suggestion cause it happens inside post-update hook, but i'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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论