Jenkins continuous deployment project

->This project will trigger any changes in the code in GitHub and trigger those changes using GitHub webhook to Jenkins where a job is created to build and run the code using docker-compose and deploy on ec2 instance.

  • -> First, create a job, and fill in the details.

  • Source code management

Repository URL: https://github.com/ManishNegi963/node-todo-cicd.git

Branch: master

  • Build Triggers

GitHub hook trigger for GITScm polling: It will constantly poll to the webhook (URL) created in the GitHub for any change and if any changes it will trigger a new build.

  • Create a webhook in GitHub.

-Go to settings->copy and paste the IP address of the ec2 and with port 8080( as Jenkins work on port 8080) and add /github-webhook/ at the end

-Select the event you want which will trigger this webhook as Just the push event.

  • Build steps

To down the docker container and release port

docker-compose down

To run and build the container(--no-deps refers to no dependencies every time it will create a fresh container for service web)

docker-compose up -d --no-deps --build-web

  • ->Now, open port 8000 on the security group of the ec2 instance as the project has exposed port 8000.

  • ->Now, go to GitHub->node-todo-cicd/views/todo.ejs and commit any changes in the master branch

Committed Jenkins is amazing

  • ->This will trigger a build as there is a push event(commit) in the master branch and it will automatically start the build.

  • ->Go to the browser and paste the IP address with port 8000, code changes have been deployed automatically.

  • Now, if the developers have committed some more changes in the code, it will automatically create a build, and deploy the changes.

Jenkins is amazing and awesome

  • A new build has been started automatically.

  • The changes committed have been deployed.