使用Jenkins进行Go应用程序的持续集成(CI)

huangapple go评论95阅读模式
英文:

Go app CI with Jenkins

问题

我尝试为Go应用程序和Jenkins设置CI。已安装Jenkins Go插件,它获取到正确的Go版本(目前是1.5.2)。

目前我有以下内容:

  1. 带有简单应用程序的测试存储库https://github.com/Agnikay/Test-Go-Jenkins

  2. 安装了Go插件的Jenkins(在VPS上,Ubuntu 14.04,x86)

  3. 在Jenkins中添加了构建步骤:

    cd src/main go build main.go

结果,构建产物中存在两个文件 - main.go(源代码)和main(可执行文件)适用于Linux x86。如果我使用构建命令go build main.go -o server,会收到错误消息:"命名的文件必须是.go文件"。
所以,我的问题是:

  1. 如果我的应用程序包含更多的代码文件、包等,我是否仍然应该像go build main.go一样构建它?
  2. 如何正确命名go build的输出文件以将其添加到构建产物中?
  3. 我是否应该在构建机器上使用某种类型的make文件/脚本等来收集依赖项?这里有什么最佳实践?
英文:

I try to setup CI for Go app and Jenkins. Jenkins Go Plugin has been installed, it gets correct version of Go(currently it's 1.5.2).

Currently I have next:

  1. Test repository with simple app https://github.com/Agnikay/Test-Go-Jenkins

  2. Jenkins with installed Go Plugin(on VPS, Ubuntu 14.04, x86)

  3. For build in Jenkins added as build step next:

    cd src/main
    go build main.go

As result in artifacts existing 2 files - main.go(sources) and main (executable) for linux x86. If i use as build command go build main.go -o server error received: "named files must be .go files".
So, my questions are

  1. If my app will contain much more code file, packages etc. should i still build it as go build main.go?
  2. How correctly give name for go build output file to add it to the artifacts?
  3. Should i use some kind of make file/script etc to collect dependencies on build machine? What is best practice here?

答案1

得分: 0

命名的文件必须是.go文件。

你需要将.go文件放在命令行的最后。

go build -o server main.go

参考:

相关链接:

英文:

> named files must be .go files

You need to put the .go file last on the command-line.

go build -o server main.go

See:

Related:

huangapple
  • 本文由 发表于 2016年1月12日 05:27:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/34731416.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定