我嘗試通過首先從 git 克隆一個反應專案,然后在我的本地機器上構建專案來實作 CI/CD 管道。
我已經重新安裝了節點,在 jenkins 中配置了 nodejs 并嘗試添加 PATH 但對我沒有任何用..
我嘗試的方法一:我創建了一個自由式專案,并在從 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 '[email protected]: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 .
我是詹金斯的新手,并且堅持了很長時間......感謝這方面的任何幫助。
謝謝
uj5u.com熱心網友回復:
export PATH=/opt/homebrew將覆寫存盤在 $PATH 中的所有路徑,以將其替換為唯一的路徑。
這不會很好地作業,因為將不再參考所有系統命令。
通常,您會將npm 路徑添加到現有 PATH
export PATH="/usr/local/bin/npm:/usr/local/bin/node:/usr/local/bin:$PATH"
(加上可能是你現有的 npm 包路徑)
確保您的 Jenkins 主控制器和代理使用您的帳戶(而不是 root)運行,以便它們繼承您的環境變數。
因此,首先檢查npm或git從您的 shell 會話中正常作業,然后啟動 Jenkins,并嘗試執行管道。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/516123.html
