jenkins - 步骤不在詹金斯管道中运行,并退出代码-2
问题描述
结果:
npm config set registry https://registry.npm.taobao.org
npm config set 'sass-binary-site=http://npm.taobao.org/mirrors/node-sass'
process apparently never started in /home/jenkins/workspace/demo_nodejs@tmp/durable-a15f6a06
ERROR: script returned exit code -2
Finished: FAILURE
还有我的管道脚本(秘密是我的秘密信息):
def registry = SECRET
def library = 'demo'
def name = 'nodejs_demo'
podTemplate(){
node('nodejs') { // my podtemplate is defined in global config, and can run well.
echo 'ready go'
def path = pwd()
def branch_ = ''
def author = ''
def version = ''
def image
branch_ = 'master'
echo 'branch_ = ' + branch_
// clone git
stage("clone code") {
git credentialsId: SECRET, branch: branch_, url: SECRET
sh 'git log --no-merges --pretty=format:"%an" -1 > author.txt'
sh 'git log --no-merges --pretty=format:"%h" --abbrev=8 -1 > version.txt'
sh 'url=`cat .git/config|grep git`&&url=${url##*/}&&echo ${url%.*} > name.txt'
author = readFile("author.txt")
version = readFile("version.txt")
image = "${registry}/${library}/${name}"
echo "${image}"
echo 'clone code complete'
}
# enter container.
container('nodejs') {
stage("nodejs install") { // my Step
sh 'npm config set registry https://registry.npm.taobao.org'
sh 'npm config set sass-binary-site=http://npm.taobao.org/mirrors/node-sass'
sh 'npm install' // not execute it.
}
stage("nodejs build") {
sh 'npm run build'
}
stage('copy dockerfile') {
input "Exit"
}
}
}
}
地位:
“npm install”或“npm build”在我的 jenkinsfile 中定义。
当脚本运行“npm config” 在我的 jenkinsfile 中,下一步是“npm install”,但它没有运行,我的工作流程是退出。
我使用相同的 jenkinsfile,如果我很幸运,我可以收到成功消息。
错误将在其他位置发生,例如在“npm install”之后或“npm build”之后很快。
解决方案
请检查您的全局配置或节点配置中是否有空的环境变量。
推荐阅读
- javascript - SyntaxError:导入声明只能出现在带有 gulp 网页的模块的顶层
- c# - 服务总线重试逻辑:更喜欢队列重试还是实现 Polly?
- tkinter - tkinter:具有不同颜色的进度条
- c++ - 删除列表的一部分 C++
- ios - 将 Unicode 字符串显示为表情符号
- windows - 是否可以使用具有与管理员相同的浏览器数据的 RDP?
- c# - 如何在 UWP 中更改 AppBarButton 字体大小?
- sql-server - 如何转换具有层次结构的表?
- android - 在 Kotlin 中单击按钮将活动旋转 180 度
- javascript - Windows机器中未更新环境变量