๐น Recap
This week was all about Jenkins. I built multiple pipelines and deployed my Node.js app to AWS EC2 using Jenkins. Now, when I update my GitHub repo and click Build Now, Jenkins automatically updates my app on EC2.
โ Achievements
Set up Jenkins on my server
Configured Jenkins pipeline for Node.js app
Connected GitHub โ Jenkins โ EC2 deployment
Used PM2 to manage and restart the Node.js app
Automated CI/CD successfully ๐
๐น Jenkins Pipeline Script
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
url: 'https://github.com/Azmat-Ahmed/deploycicd.git'
}
}
stage('Dependencies') {
steps {
sh 'npm install'
}
}
stage('Deploy') {
steps {
sh """
ssh -o StrictHostKeyChecking=no -i /var/lib/jenkins/test.pem ubuntu@ << 'EOF'
cd /home/ubuntu/deploycicd
git pull origin main
npm install
pm2 restart app.js || pm2 start app.js
EOF
"""
}
}
}
}
๐ฏ Whatโs Next?
In the next stage of my journey, I will be exploring:
GitHub Webhooks โ for fully automated Jenkins triggers
GitHub Actions โ GitHubโs native CI/CD tool
But for now, I can confidently say: Week 10 = Jenkins Mastery โ
๐ My portfolio: https://azmatahmed.netlify.app
Top comments (0)