Skip to main content

Command Palette

Search for a command to run...

Day 24 Task: Complete Jenkins CI/CD Project

Published
2 min read
A

DevOps | Cloud Practitioner | AWS | GIT | Kubernetes | Terraform | ArgoCD | Gitlab

Step 1 : Generate a secret token / Personal Access Token in github

Go to: Github > Settings> Developer Settings
In developer settings, go to Personal Access Tokens (PAT) > Tokens(Classic)

Generate New Token: Pro tip “save somewhere, it will disappear”

Step 2: Clone your github project into your EC-2 instance

Go to: Github Repo https://github.com/amitsinghs98/node-todo-cicd
This is my repo I have forked this from #shubhamLondhe github

Copy the HTTP path: Go to your EC-2 machine
clone the git repo
Command: $ git clone https://github.com/amitsinghs98/node-todo-cicd.git
$ git remote -v

Step 3: Integrate Jenkins with Github

Go to Jenkins: Manage Jenkins and Install Plugin

Called: “Git Client”

Now go to your Manage Jenkins: System Configuration > System ( to integrate github with jenkins)

Add “Github Server”

Click on Add and Select the Jenkins

In secret key: Put Your PAT “Personal Access Token” in secret text

After all this “SAVE” : You have successfully integrated Jenkins and Github

Step 4: Create freestyle Jenkins job

Create a freestyle job: Go to SCM > Add Repo URL

Note: No need to add credential here, we already did earlier in settings.

Create a Jenkins Job to Use Docker Compose:

  • Go to your Jenkins Job configuration and scroll down to the Build section.

  • Add a Build Step and select Execute Shell.

  • In the shell script section, add the following commands to run Docker Compose and start the app:

This command will build the Docker image and start the Node.js app in the background using Docker Compose.

Create a GitHub Webhook:

  • In your GitHub repository, navigate to Settings > Webhooks.

  • Click on Add webhook, and in the Payload URL field, enter your Jenkins server's webhook URL (typically http://<your_jenkins_url:ip-port>/github-webhook/).

  • Set the content type to application/json.

  • Choose to send events for push and pull request events.

  • Save the webhook.

Post-Completion Actions:

  1. Testing:

    • Once the Jenkins job completes, verify the application is running by accessing the exposed port in your browser (e.g., http://localhost:3000/).

    • Check Jenkins logs to make sure everything was built and deployed correctly.

  2. Push Changes to GitHub:

    • Push any changes or improvements you made (like the Dockerfile or Docker Compose file) back to your GitHub repository. This ensures your CI/CD pipeline will always run with the latest code.
  3. Share Your Experience:

    • Share your project and experiences on LinkedIn using the hashtag #90DaysOfDevOps. Highlight the steps you took to complete the task, any challenges you faced, and how you overcame them.

More from this blog

DevOps Projects and Blog

69 posts