Day 24 Task: Complete Jenkins CI/CD Project

Day 24 Task: Complete Jenkins CI/CD Project

Day 24 of #90DaysOfDevOps: Completing Jenkins CI/CD Project

Welcome to Day 24 of the #90DaysOfDevOps challenge! Today, we're diving into the exciting world of Jenkins CI/CD pipelines. By the end of this article, you'll have a fully functional CI/CD pipeline set up for your Node.js application, ready to automate your build and deployment processes.

Task 01: Setting up Jenkins with GitHub Integration

To start, fork the repository provided for this project. This repository contains a simple Node.js application that we will use for our CI/CD pipeline.

Next, we need to set up Jenkins to integrate with our GitHub repository. This integration allows Jenkins to automatically trigger builds whenever changes are pushed to the repository.

  1. Install the GitHub Integration plugin in Jenkins.
  2. In Jenkins, navigate to Manage Jenkins > Manage Plugins > Available tab, search for "GitHub Integration", select the checkbox next to it, and click Install without restart.
  3. Once the plugin is installed, go to Manage Jenkins > Configure System and scroll down to the GitHub section.
  4. Click on Add GitHub Server and add your GitHub credentials.
  5. Back in the Jenkins dashboard, create a new job by clicking on New Item, enter a name for your job (e.g., NodeJS-CI-CD), select Freestyle project, and click OK.
  6. In the job configuration page, scroll down to the Source Code Management section and select Git.
  7. Enter the URL of your forked GitHub repository in the Repository URL field.
  8. In the Build Triggers section, select GitHub hook trigger for GITScm polling.
  9. Save your job configuration.

Task 02: Running the Application with Docker Compose

Now that Jenkins is set up to integrate with GitHub, let's configure our build process to run the Node.js application using Docker Compose.

  1. Create a docker-compose.yml file in the root of your project directory with the following content:
  2. Modify your Jenkins job configuration to include a build step to run the application using Docker Compose:
  3. Save your job configuration.

Example:

Let's say your GitHub repository is https://github.com/your-username/nodejs-app. After forking this repository, the URL will be https://github.com/your-username/nodejs-app.

Your docker-compose.yml file should look like this:


version: '3'
services:
  app:
    image: node:latest
    volumes:
      - .:/app
    working_dir: /app
    command: npm start
    ports:
      - "3000:3000"
        

And the build step in your Jenkins job configuration should include:

docker-compose up -d        

Conclusion:

Congratulations! You have successfully completed Day 24 of the #90DaysOfDevOps challenge. You have set up a Jenkins CI/CD pipeline for your Node.js application, integrating with GitHub and running the application using Docker Compose. Keep up the great work, and stay tuned for more exciting challenges ahead!

Utsav Bayaskar

Sr Analyst / Software Engineer at Capgemini

6 个月

Happy Learning!!

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了