doudu9094 2016-05-16 20:27
浏览 322
已采纳

Jenkins为Go Projects构建设置

We are planning to setup Jenkin Build process for Go Projects. I setup Custom Workspace in jenkins and installing go1.6 from "Global Tool Configuration".

I am getting error message while executing go build Below is the GOPATH and GOROOT

GOPATH /var/lib/jenkins/workspace/project/go
GOROOT  /var/lib/jenkins/workspace

ain.go:20:2: cannot find package "bytes" in any of:
    /var/lib/jenkins/workspace/src/pkg/bytes (from $GOROOT)
    /var/lib/jenkins/workspace/project/go/src/bytes (from $GOPATH)

What I am missing here?.. Thanks for your help..

  • 写回答

5条回答 默认 最新

  • duanjiao5082 2016-09-13 19:57
    关注

    In addition to letting the Go plugin handle your GOROOT, there are some nuances to the GOPATH as well when it comes to getting dependencies. We are putting our *.go source files in the root of our Git repositories, so they are easily managed via go commands on the Dev desktops. So, I am using a build script to trick Go into thinking there is a package called main under /src/main via a symlink so that I can use the same script to build all of my go packages and pull the dependencies. Here is my build script:

    #!/usr/bin/bash export GOPATH=$WORKSPACE mkdir -p $GOPATH/src ln -f -s $WORKSPACE $GOPATH/src/main go get main CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main main

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大