Reulst:
npm配置集注册表https://registry.npm.taobao.org
npm配置集'sass-binary-site = http://npm.taobao.org/mirrors/node-sass'
进程显然从未在/ home / jenkins / workspace / demo_nodejs @ tmp / durable-a15f6a06中启动
错误:脚本返回退出代码-2
完成:失败
还有我的管道脚本(SECRET是我的秘密信息):
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”之后不久。
您是否尝试连接到Pod并从中运行NPM命令?您可以在失败之前添加一个睡眠步骤,然后连接到pod并在pod中运行npm命令。