Gitlab CI/CD fail with "bash: line 132: go: command not found"
We have installed Gitlab on our custom server. We are looking to use the gitlab CI/CD pipeline to build and release our software for that I'm working on a POC. I have created a project with the following 开发者_高级运维.gitlab-ci.yml
image: golang:latest
variables:
GOOS: linux
GOARCH: amd64
stages:
- test
- build
run_tests:
stage: test
image: golang:latest
before_script:
- ls -l
- hostname
- ruby -v
- which go
script:
- go mod tidy
- go test -race ./...
build_binary:
stage: build
image: golang:latest
script:
- GOOS=$GOOS GOARCH=$GOARCH go build -o newer .
Since you have used image: golang:latest
, go
should be in the $PATH
You need to check at which stage it is failing: run_tests
or build_binary
.
Add echo $PATH
in your script steps, to check what $PATH is considered.
Check also if the error comes from the lack of git
, used by Go for accessing modules remote repositories. See this answer as an example.
精彩评论