我的 Gitlab CI Auto DevOps 作业失败了
Status: Downloaded newer image for gliderlabs/herokuish:latest
-----> Unable to select a buildpack
ERROR: Job failed: exit code 1
我经历过
我仍然不确定我应该把 buildpack 放在哪里。
我的应该是 heroku-buildpack-go
,我已经忘记从哪里得到它了。
我的 repo 仅包含一个单字符 README.md
和“Hello, playground” main.go
。
结论:
感谢 David 的全面解释,我能够使用正确的构建包开始 DevOps:
From this I would conclude that your single .go file at the root of the directory tree does not meet the activation criteria for auto-building Go projects. I'd suggest picking one of the dependency managers in the requirements above and modifying your project to support it.
FTA,我只是做了 touch go.mod
然后是 git add
& git push
AutoDevops 确实开始构建我的 GO 项目。
但是在我看来,Gitlab AutoDevops 无法非常轻松地构建任何 GO 项目,因为我收到以下错误(项目变量 TRACE=true
):
...
!! The go.mod file for this project does not specify a Go version
!!
!! Defaulting to go1.11.1
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Installing go1.11.1
-----> Fetching go1.11.1.linux-amd64.tar.gz... done
!! Installing package '.' (default)
!!
!! To install a different package spec add a comment in the following form to your `go.mod` file:
!! // +heroku install ./cmd/...
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Running: go install -v -tags heroku .
go: cannot determine module path for source directory /tmp/build (outside GOPATH, no import comments)
ERROR: Job failed: exit code 1
更简单的解决方案是使用 .gitlab-ci.yml
文件,记录在
https://blog.boatswain.io/post/build-go-project-with-gitlab-ci/
(并在 Gitlab CI - Start Shared Runner for normal repos 跟进)。
最佳答案
Auto Build creates a build of the application in one of two ways:
- If there is a Dockerfile, it will use docker build to create a Docker image.
- Otherwise, it will use Herokuish and Heroku buildpacks to automatically detect and build the application into a Docker image.
然后根据 Heroku Go buildpack 查看构建激活标准文档:
This buildpack will detect your repository as Go if you are using either:
或more specifically for godep, govendor or GB :
The Heroku Go buildpack is used when an application meets one of the following requirements:
- has a
Godeps/Godeps.json
file, identifying the application as being managed by godep;- has a
vendor/vendor.json
file, identifying the application as being managed by govendor;- has a
src
directory, which has sub directories, contains one or more .go files, identifying the application as being managed by gb.
由此我可以得出结论,目录树根目录下的单个 .go
文件不符合自动构建 Go 项目的激活条件。我建议在上述要求中选择一个依赖管理器并修改您的项目以支持它。之后 AutoDevops 应该开始构建您的项目。
如果在那之后您仍然遇到问题,这 debugging note可能有帮助:
After making sure that the project meets the buildpack requirements; if it still fails, setting a project variable
TRACE=true
will enable verbose logging which may help to continue troubleshooting.
关于go - Gitlab CI - Auto DevOps 作业失败,无法为 Go 项目选择构建包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53215063/