开发者

Gitlab CI/CD fail with "bash: line 132: go: command not found"

开发者 https://www.devze.com 2022-12-07 19:57 出处:网络
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 follo

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号