我有一個簡單的 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 關注
- 112 瀏覽
添加回答
舉報
0/150
提交
取消