java 单机接口限流处理方案
253
2022-11-02
Jenkins 常用的项目构建工具集成 03 GO
Go项目构建工具
先安装go的开发环境
cicd]# tar zxf go1.16.3.linux-amd64.tar.gz -C /usr/local/[root@zeyang-nuc-service cicd]# cd /usr/local/go/[root@zeyang-nuc-service go]# lsAUTHORS CONTRIBUTORS PATENTS SECURITY.md api doc lib pkg srcCONTRIBUTING.md LICENSE README.md VERSION bin favicon.ico misc robots.txt test[root@zeyang-nuc-service go]# pwd/usr/local/go[root@zeyang-nuc-service go]# vi /etc/profileexport GOROOT=/usr/local/goexport PATH=$GOROOT/bin:$PATH[root@zeyang-nuc-service go]# source /etc/profile[root@zeyang-nuc-service go]# go versiongo version go1.16.3 linux/amd64
常用命令
go clean 清空构建go build 构建源文件go doc 生成godoc文档go install 编译并安装指定的代码包go fmt 代码格式化go get 获取一个包go run 运行一个go文件go test 运行测试
[root@jenkins-master ~]# cd devops-golang-service-master[root@jenkins-master devops-golang-service-master]# lsdemo.go Jenkinsfile README.md[root@jenkins-master devops-golang-service-master]# go build demo.go [root@jenkins-master devops-golang-service-master]# lsdemo demo.go Jenkinsfile README.md[root@jenkins-master devops-golang-service-master]# ./demo Hello World![root@jenkins-master devops-golang-service-master]# go run demo.go Hello World!
Pipeline样例
def buildTools = ["golang": "/usr/local/go"]pipeline { agent { label "build" } options { skipDefaultCheckout true } stages { stage("GetCode"){ steps{ script{ println("下载代码 --> 分支: ${env.branchName}") checkout([$class: 'GitSCM', branches: [[name: "${env.branchName}"]], extensions: [], userRemoteConfigs: [[credentialsId: '823b86fe-2c1b-466e-b0c3-66ae6991449d', url: "${env.gitHttpURL}"]]]) } } } stage("Build"){ steps { script { sh "${buildTools["golang"]}/bin/go build demo.go" } } } }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~