我正在为我们的内部NodeJS Express项目设置Jenkins构建。
该项目使用一些本机库(用C语言编写)。经过试验和错误设置Python,MSBuild工具(使用windows-build-tools
和没有),我没有设法使构建工作。
詹金斯剧本:
pipeline {
agent any
stages {
stage('Download source') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/branch-name']],
userRemoteConfigs:
[
[
credentialsId: 'cred-id',
url: 'gitURL'
]
]
])
}
}
stage('Npm install') {
steps {
bat "npm install"
}
}
}
}
我尝试过NodeJS插件,同样的问题。授予C:\Program Files (x86)\Jenkins
文件夹和每个子目录的权限,重新安装所有内容(包,具有不同版本的节点,甚至我的Windows操作系统),但输出始终为:
step: npm install
npm ERR! premature close
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2019-04-04T16_69_111Z-debug.log
奇怪的是,当我从npm install
文件夹运行%JENKINS_HOME%workspace/ProjectName
时,它会构建并安装所有内容而不会出现任何警告或错误并且运行顺畅。
抱歉,我已经对这个主题进行了为期3周的研究,看了很多文章和帖子,但这个问题已经存在了很长一段时间,我们无法管理构建任何Node项目。
好的,经过2个星期的悲惨尝试才能完成这项工作,唯一有效的解决方案是:
yarn install
代替:
npm install