Go语言:自动化测试时Jenkins报错build cache is required, but could not be located: GOCACHE is not defined and ne

Go语言:自动化测试时Jenkins报错build cache is required, but could not be located: GOCACHE is not defined and ne,第1张

 Jenkins执行脚本来运行go的命令时,可能会因为读取不到相关的环境变量而报如下错误,

build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined

解决方案:把go env命令打印出来的环境变量写成export语句加到脚本里,如下所示:

export GO111MODULE=""
export GOARCH="amd64"
export GOBIN=""
export GOCACHE="/root/.cache/go-build"
export GOENV="/root/.config/go/env"
export GOEXE=""
export GOFLAGS=""
export GOHOSTARCH="amd64"
export GOHOSTOS="linux"
export GOINSECURE=""
export GOMODCACHE="/usr/local/go-proj/pkg/mod"
export GONOPROXY=""
export GONOSUMDB=""
export GOOS="linux"
export GOPATH="/usr/local/go-proj"
export GOPRIVATE=""
export GOPROXY="https://mirrors.aliyun.com/goproxy/"
export GOROOT="/usr/local/go"
export GOSUMDB="sum.golang.org"
export GOTMPDIR=""
export GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
export GCCGO="gccgo"
export AR="ar"
export CC="gcc"
export CXX="g++"
export CGO_ENABLED="1"
export GOMOD=""
export CGO_CFLAGS="-g -O2"
export CGO_CPPFLAGS=""
export CGO_CXXFLAGS="-g -O2"
export CGO_FFLAGS="-g -O2"
export CGO_LDFLAGS="-g -O2"
export PKG_CONFIG="pkg-config"
export GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build162435450=/tmp/go-build -gno-record-gcc-switches"

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/996294.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存