栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

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

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

 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"

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/910258.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号