Step 1) Install & Configure Jenkins in Ubuntu
Step 2) Integrating GitHub with Jenkins
Step 3) Integrating Slave Node (also known as Agent) as Remote Server in Jenkins
Step 4) Configure Build Steps for Reactjs app
Select Project 👉 Build Steps 👉 Execute shell
- export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v18.20.4/bin
- npm install
- npm run build
- pm2 restart Frontend || pm2 start server.js --name "Frontend"
- rm -rf /var/www/html/React-Server/workspace/React-App-Frontend-CI-CD@tmp
Step 5) To receive an ✉️ email notification whenever a Jenkins job is executed. (Optional)
a) Add Gmail SMTP Credential In Jenkins
- Manage Jenkins 👉 Credentials 👉 Global 👉 Add Credential 👉 Username & Password
b) Configure SMTP Server for Sending Emails ✉️ In Jenkins
- Manage Jenkins 👉 Configure System 👉 Scroll down to "Extended E-mail Notification"
SMTP server: smtp.gmail.com
SMTP server: 465
- Click On Advance 👉 Select SMTP Credential 👉 Use SSL
Expend "Default Trigger" 👉 Select Always
c) Configure Job-level Email ✉️ Notifications
- Dashboard 👉 Project 👉 Configure 👉 Scroll down to "Post-build Actions"
Click Add post-build action and select Editable Email Notification.
- Project Recipient List 👉 Add End User email address 👉 Save
d) Check Notification in the ✉️ Inbox!
Related Article 😱
- How To Genrate Gmail STMP
- How To Setup Default Reactjs App
- Install & Configure Jenkins in Ubuntu
- Integrating Github With Jenkins
- how to Deploying ReactJS Docker Container Via jenkins
- Integrating Slave Node (also known as Agent) as Remote Server in Jenkins
==============================================================================================
⚠️ Error 1) "+ npm install" "/tmp/jenkins12534206624344975805.sh: 2:" "npm: not found Build step 'Execute shell' marked build as failure"
It seems like Jenkins is unable to find the npm command when running the build script, even though npm works fine when manually executed on the server.
a) Verify Jenkins has npm access or not ? (Optional)
- sudo -u jenkins -i
- npm -v
b) Find out where npm is located by running:
- which npm
c) In the Jenkins job's shell script, add the PATH till "bin" to include the directory where npm is located:
- export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v18.20.4/bin
No comments:
Post a Comment
testing