Gitlab CI - Auto DevOps job failed, Unable to sele

2019-06-23 07:47发布

My Gitlab CI Auto DevOps job failed with

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

I've gone through

and am still not sure where I should put the buildpack.

Mine should be heroku-buildpack-go, which I've lost track where I get that from.

My repo consist only a single-character README.md, and the "Hello, playground" main.go.

Conclusion:

Thanks to David's comprehensive explanation, I was able to get DevOps started with correct buildpack:

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, I just did touch go.mod then git add & git push and the AutoDevops started building my GO project indeed.

However it seems to me that Gitlab AutoDevops is not able to build any GO projects very easily, as I get the following error (with project variable 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

The easier solution is to use .gitlab-ci.yml file instead, documented in
https://blog.boatswain.io/post/build-go-project-with-gitlab-ci/
(and followed up at Gitlab CI - Start Shared Runner for normal repos).

1条回答
冷血范
2楼-- · 2019-06-23 08:24

From the 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 Herokuish and Heroku buildpacks to automatically detect and build the application into a Docker image.

Then looking at the build activation criteria, as per the Heroku Go buildpack documentation:

This buildpack will detect your repository as Go if you are using either:

Or 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.

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. After that AutoDevops should start building your project.

If you are still having issues after that, this debugging note might help:

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.

查看更多
登录 后发表回答