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 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)