英文:
Go app CI with Jenkins
问题
我尝试为Go应用程序和Jenkins设置CI。已安装Jenkins Go插件,它获取到正确的Go版本(目前是1.5.2)。
目前我有以下内容:
-
带有简单应用程序的测试存储库https://github.com/Agnikay/Test-Go-Jenkins
-
安装了Go插件的Jenkins(在VPS上,Ubuntu 14.04,x86)
-
在Jenkins中添加了构建步骤:
cd src/main go build main.go
结果,构建产物中存在两个文件 - main.go(源代码)和main(可执行文件)适用于Linux x86。如果我使用构建命令go build main.go -o server
,会收到错误消息:"命名的文件必须是.go文件"。
所以,我的问题是:
- 如果我的应用程序包含更多的代码文件、包等,我是否仍然应该像
go build main.go
一样构建它? - 如何正确命名
go build
的输出文件以将其添加到构建产物中? - 我是否应该在构建机器上使用某种类型的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:
-
Test repository with simple app https://github.com/Agnikay/Test-Go-Jenkins
-
Jenkins with installed Go Plugin(on VPS, Ubuntu 14.04, x86)
-
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
- If my app will contain much more code file, packages etc. should i still build it as
go build main.go
? - How correctly give name for
go build
output file to add it to the artifacts? - 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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论