【发布时间】:2018-11-28 20:33:02
【问题描述】:
我的 JenkinsFile 脚本开始抛出 npm not found 错误。 (它适用于 maven,但在 npm 失败)
pipeline {
environment {
JENKINS='true'
}
agent any
stages{
stage('change permissions') {
steps {
sh "chmod 777 ./mvnw "
}
}
stage('clean') {
steps {
sh './mvnw clean install'
}
}
stage('yarn install') {
steps{
sh 'npm install -g yarn'
sh 'yarn install'
}
}
stage('yarn webpack:build') {
steps {
sh 'yarn webpack:build'
}
}
stage('backend tests') {
steps {
sh './mvnw test'
}
}
stage('frontend tests') {
steps {
sh 'yarn test'
}
}
}
}
解决这个问题 我正在尝试在我的 jenkins 节点上设置 NodeJs。我安装了nodejs插件并编写了脚本
pipeline {
agent any
stages {
stage('Build') {
steps {
nodejs(nodeJSInstallationName: 'Node 6.x', configId: '<config-file-provider-id>') {
sh 'npm config ls'
}
}
}
}
}
如https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin所示 我还在全局工具配置中设置了 nodejs
我也尝试了installing node on jenkins 2.0 using the pipeline plugin中的解决方案
它抛出 预计会在第 4 行第 7 列找到‘someKey "someValue"'。 节点{ 错误。 但我仍然在 jenkins 上收到 npm not found 错误。我是詹金斯的新手,因此不胜感激。 提前致谢
我能够解决这些问题。按照以下链接并能够解决该问题。 https://medium.com/@gustavo.guss/jenkins-starting-with-pipeline-doing-a-node-js-test-72c6057b67d4
【问题讨论】:
-
如果不了解您的项目设置,这真的很难回答。您应该提供更多信息或在 Google 上解决问题。
-
我已经编辑了帖子并提供了更多信息,如果它可以帮助您更多地了解我的问题,请告诉我
-
您提到您能够解决问题 - 我认为您应该发布该链接并附上简短的解释,作为下一位前来寻找此问题的人的答案。很高兴你让它工作了!
-
@saiharshini - 你得到
yarn命令工作了吗?如果有,怎么做? -
@kwhitejr medium.com/@gustavo.guss/… 我按照本网站的说明进行操作。在我的文件中,一旦我添加它对我有用,我就丢失了“工具 {nodejs “node”}”。