我有一个简单的 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 "
}
- 1 回答
- 0 关注
- 116 浏览
添加回答
举报
0/150
提交
取消