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条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决