为了账号安全,请及时绑定邮箱和手机立即绑定

如何在本地运行 go 二进制文件作为 Jenkins 管道的最后阶段?

如何在本地运行 go 二进制文件作为 Jenkins 管道的最后阶段?

Go
陪伴而非守候 2022-06-01 11:27:09
我有一个简单的 gin gonic 微服务 Golang 项目,我用它来学习如何制作 Jenkins 管道。每个阶段都成功运行,但在管道完成后二进制文件没有运行。还可以通过使用 curl 命中端点来判断进程没有运行:卷曲http://localhost:9191/users这是有问题的管道:pipeline {   agent any   stages {      stage('git') {         steps {            echo "git"            git 'https://github.com/eduFDiaz/golang-microservices.git'         }      }      stage('clean') {         steps {            echo "clean"            sh "make clean"         }      }      stage('test') {         steps {            echo "test"            sh "make test"         }      }      stage('build') {         steps {            echo "build"            sh "make build"         }      }      stage('run') {         steps {            echo "run"            sh "make run"         }      }   }}生成文件:executableName=testApiclean:    echo "stoping if running and cleaning"    rm -rf ./bin    killall $(executableName) || truetest:    echo "Testing..."    go test -coverprofile cp.out ./mvc/...    go tool cover -html=cp.outbuild:    echo "Building..."    go build -o bin/$(executableName) mvc/main.gorun:    echo "Running..."    ./bin/$(executableName) &all: test build run当我手动完成时,一切都运行良好。我在这里想念什么?
查看完整描述

1 回答

?
繁星淼淼

TA贡献1775条经验 获得超11个赞

出现此问题是因为 Jenkins 正在清理在构建期间启动的所有子进程。即 make run 正在启动应用程序,但 Jenkins 正在杀死该进程作为清理的一部分(有关更多详细信息,请搜索“ProcessTreeKiller”)。


要解决更新您的行如下


stage('run') {

steps {

echo "run"

sh "export JENKINS_NODE_COOKIE=dontKillMe; make run "

}


查看完整回答
反对 回复 2022-06-01
  • 1 回答
  • 0 关注
  • 116 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号