问题
默认情况下,jenkins pipiline 会kill 掉衍生后台的子进程,比如nohup 命令等。
解决
设置环境变量即可。withEnv(['JENKINS_NODE_COOKIE=dontKillMe'])
sh
stage('上传到阿里云OSS') {
steps{
script {
withEnv(['JENKINS_NODE_COOKIE=dontKillMe']){
sh 'source /data/jenkins/archive-package/cloudoss/bin/activate && nohup python3 /data/jenkins/archive-package/KFPackageUpALiCloudOss.pyc -l ${JENKINS_HOME}/archive-package/${namespace}/${JOB_BASE_NAME}/${branches_name}-${BUILD_NUMBER}/${JOB_BASE_NAME}.jar -r ${namespace}/${JOB_BASE_NAME}/${branches_name}-${BUILD_NUMBER}/${JOB_BASE_NAME}.jar &'
echo '\033[32m======================上传到阿里云OSS完成======================\033[0m'
}
}
}
}