Gitlab CI – Auto DevOps作业失败,无法为Go项目选择buildpack?

我的
Gitlab CI Auto DevOps作业失败了

Status: Downloaded newer image for gliderlabs/herokuish:latest
       -----> Unable to select a buildpack
ERROR: Job failed: exit code 1

我经历过

> Auto DevOps
> Getting started with Auto DevOps

我仍然不确定我应该把buildpack放在哪里.

我应该是heroku-buildpack-go,我已经失去了我从那里得到的轨道.

我的repo只包含一个单字符README.md和“Hello,playground”main.go.

结论:

感谢David的全面解释,我能够使用正确的buildpack启动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.

自由贸易协定,我刚刚触摸了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进行了跟进).

最佳答案 从
AutoDevops documentation

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 07001 and 07002 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:

  • 07004
  • 07005
  • 07006
  • 07007
  • 07008
  • 07009

more specifically for godep, govendor or GB

The 07003 is used when an application meets one of the following requirements:

  • has a Godeps/Godeps.json file, identifying the application as being managed by 070012;
  • has a vendor/vendor.json file, identifying the application as being managed by 070013;
  • has a src directory, which has sub directories, contains one or more .go files, identifying the application as being managed by 070014.

由此我得出结论,目录树根目录下的单个.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.

点赞