I tried to implement CI/CD pipeline by first cloning a react project from git and then build the project in my local machine.
I have reinstalled node, configured nodejs in jenkins and tried adding PATH but nothing worked for me..
Method one that i tried: I create a freestyle item and added below script after providing the git repo link under pipeline script from SCM.. this is throwing me npm command not found error.
export PATH=/opt/homebrew
npm install
Edit:
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
Second method i tried is by creating a new pipeline item and passing pipeline script as below.
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'
}
}
}
}
Edit:
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
.
I am new to jenkins and stuck with this for a long time...Appreciate any help in this regard.
Thank you