jenkins - 在詹金斯管道中运行 npm install 的问题
问题描述
我在尝试npm i
在 jenkins 管道中运行命令时遇到问题,我尝试了几种解决方案,但到目前为止都没有成功。
詹金斯文件
node {
env.NODEJS_HOME = "${tool 'node'}"
env.PATH = "${env.NODEJS_HOME}/bin:${env.PATH}"
def app
def workspace = env.WORKSPACE
def version
def version_qa
def app_name = "apresentacao"
def image_name = "menu"
def image = "myhub/${image_name}"
def git_url = "bitbucket.org/myuser/myrepo.git"
stage('Clone repository') {
git branch: 'master',
credentialsId: 'jenkins',
url: "https://myuser@${git_url}"
}
stage('Build') {
app = docker.build("${image}")
}
stage('Dependencies') {
// sh 'npm install -g node-gyp'
sh 'npm config set [--global] devdir /tmp/.gyp'
sh 'npm install'
}
stage('E2E Tests') {
sh 'npm run exec:e2e'
}
stage('Tagging') {
try {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
sh("echo ${env.GIT_USERNAME}")
sh("git config --global user.email 'email'")
sh("git config --global user.name 'Jenkins'")
sh("git config credential.username ${env.GIT_USERNAME}")
sh("git config credential.helper '!f() { echo password=\$GIT_PASSWORD; }; f'")
sh('/opt/tools/create-tag')
version = sh (script: "stepup version | sed -e 's/v//g'", returnStdout: true).trim()
echo "next-release: [${version}]"
}
} finally {
sh("git config --unset credential.username")
sh("git config --unset credential.helper")
}
}
}
错误詹金斯
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'`
Alpine users please run: `sudo apk add python make g++`
sh: 1: nodejs: not found
npm WARN ts-node@8.3.0 requires a peer of typescript@>=2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! fibers@3.1.1 install: `node build.js || nodejs build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fibers@3.1.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /var/lib/jenkins/.npm/_logs/2019-07-23T03_04_58_311Z-debug.log
解决方案
似乎失败来自安装fibers@3.1.1
,由于未找到 c/c++ 编译器,按照之前给出的提示安装编译器npm install
Windows + OS X 说明:https ://github.com/nodejs/node-gyp
Ubuntu 用户请运行:
sudo apt-get install g++ build-essential
RHEL 用户请运行:
yum install gcc-c++
和yum groupinstall'Development Tools'
高山用户请运行:
sudo apk add pythonmake g++
推荐阅读
- android - 将 sqlite 数据从一个活动发送到另一个活动
- tensorflow - 优雅地捕捉 Keras/Tensorflow 内存不足 (OOM) 问题
- php - 从 JSON 数组中获取键名
- c# - ApiControllerAttribute 和可选参数
- python - 如何在 Python 中继续运行循环
- pgadmin-4 - pgadmin4 更新到 4.11 版后坏了
- matlab - 如何使用 MATLAB 仅填充外壳的内部部分
- php - MYSQL 查询大于 AND 小于
- python - 如何将缩进格式的 json 读入字典
- python - 如何在给定该字符串的多个子字符串的情况下找到完整的字符串