NPM:在用于MAC OS的Jenkins中找不到命令

ldxq2e6h  于 2022-10-12  发布在  Mac
关注(0)|答案(0)|浏览(129)

我尝试实现CI/CD管道,方法是首先从git克隆一个Reaction项目,然后在我的本地机器上构建该项目。

我重新安装了节点,在Jenkins中配置了NodeJS,并尝试添加路径,但对我来说都不起作用。
我尝试的方法一:我创建了一个freestyle项,并在SCM的管道脚本下提供了git repo链接后,添加了下面的脚本。这是抛给我NPM命令找不到错误。

export PATH=/opt/homebrew
npm install

编辑:

I restarted jenkins and lost my old build..now, after restarting jenkins and running the build(above method 1 steps) i see groovy.lang.MissingPropertyException: No such property: install for class: groovy.lang.Binding
我尝试的第二种方法是创建一个新的管道项并传递管道脚本,如下所示。

pipeline{
agent any

tools {nodejs "default"}
stages{
    stage('Build'){
        steps{
            git 'git@github.com:patebija/simple-node-js-react-npm-app.git'
            sh 'npm install'
        }
    }
}

}

编辑:

After restarting jenkins, when i run the above steps(method 2), i still see "npm: command not found"(Not sure if**sh 'npm install'**is valid in MACOS.. And if i just give**npm install**removing sh, i get exception -- groovy.lang.MissingPropertyException: No such property: install for class: groovy.lang.Binding

我对Jenkins是新手,而且已经坚持了很长一段时间……感谢大家在这方面的帮助。

谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题