drvpv7995 2019-08-04 16:25 采纳率: 100%
浏览 264

在基于Docker的Jenkins代理中找不到Go

I have created a Docker-based Jenkins agent that uses docker:stable-dind (which is based on Alpine 3.10) as its base. Full Dockerfile.

In the Dockerfile I install Go: RUN apk add go

When running locally, e.g. go version, go env GOROOT, etc... I get results, e.g. 1.12.6, /usr/lib/go.

I then attempt using this agent in Jenkins, and print env to verify the above environment variables are, but they not there and also go version fails`.

So, I update the Docker agent template in Jenkins with:

  • GOROOT: /usr/lib/go
  • PATH:/bin/sonar-scanner/bin/:/usr/local/bin:$GOROOT/bin:$PATH

Now when checking env they are there...

GOROOT=/usr/lib/go
PATH=/bin/sonar-scanner/bin/:/usr/local/bin:/usr/lib/go/bin:/bin:/usr/bin:/sbin:/usr/sbin
GOPATH=/home/jenkins/workspace/go test

... but go version still fails.

GOPATH is set to the current $WORKSPACE as that's where I will clone the Go project source if this actually works.

This is the Jenkins job:

#!groovy

pipeline {
  agent {
    label 'cli-agent'
  }

  stages {
    stage ("test") {
      steps {
        script {
          withEnv(["GOPATH=${WORKSPACE}"]) {
             sh """
                env
                go version
             """
          }
        }
      }
    }
  }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器