Project Description
The project is about automating the deployment process of a web application using Jenkins and its declarative syntax. The pipeline includes stages like building, testing, and deploying to a staging environment. It also includes running acceptance tests and deploying to production if all tests pass.
Deploying web app using Jenkins CI/CD declarative pipeline.
Steps involved
Launch an EC2 Instance: Go to the AWS EC2 Dashboard and launch an instance with the necessary configurations.
Connect to Your Instance:
Install Jenkins and Docker on the EC2 instance.
You can refer here
Configure Jenkins for Your Project
- On the Jenkins dashboard, click "New Item."
- Enter a name for your project, select "Pipeline," and click OK.
Provide a general description, click on "GitHub project" and insert your GitHub Project url.
In the build trigger section select the GitHub webhook trigger option.
Configure the Webhook in GitHub
stages{
stage("Code"){
steps{
git url: "https://github.com/Ronke-Akinyemi/node-todo-cicd.git", branch: "master"
}
}
stage("Build & Test"){
steps{
sh "docker build . -t node-app-test-new"
}
}
stage("Push to DockerHub"){
steps{
withCredentials([usernamePassword(credentialsId:"dockerHub",passwordVariable:"dockerHubPass",usernameVariable:"dockerHubUser")]){
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}"
sh "docker tag node-app-test-new ${env.dockerHubUser}/node-app-test-new:latest"
sh "docker push ${env.dockerHubUser}/node-app-test-new:latest"
}
}
}
stage("Deploy"){
steps{
sh "docker-compose down && docker-compose up -d"
}
}
}
}
In the "Script Path" field, enter the path to your pipeline script.
Click "Save" at the bottom of the page.
- Click "Build Now" to run your pipeline.
Console output
Open port 8000 on the server to access the webpage.
Navigate to the web URL http://<public url>:8080
Thank you for reading.