Let's make a beautiful CI/CD Pipeline for your Node JS Application.
TASK-1 : Django-todo-app
We are going to set up a pipeline for a Django application.
Create a new item and choose a free-style project.
In the General setting provide the project description.
Now, go to Source code management to configure GitHub to Jenkins. Provide the GitHub URL where the code exists. Use the secret text option to provide credentials to Jenkins.
Now, go to Build Steps and choose the execute shell build option.
Guess, you have already written the docker file to containerize the application.
Provide the docker commands to build an image from the docker file and build the container.
Finally, click on build now to execute the project.
Navigate to the URL now.
Webhook
Let's automate the build process with the integration of webhook in GitHub.
GitHub webhooks give developers the ability to integrate with the GitHub platform.
Developers can subscribe to events taking place on GitHub, for example, Push events that occur when code is pushed to a repository, and respond to the event with an action.
The response action can be anything, such as making a database entry in an external application, sending an email, triggering a deployment process, and more. Actions you can perform in response to events on GitHub are only limited by your imagination.
When a subscribed event occurs on GitHub, GitHub triggers an HTTP POST request to the defined destination. This destination is specified as an HTTP URL, which is the endpoint that is to be called whenever the event occurs. This is known as the webhook URL. The endpoint handler at the webhook URL handles the action to be performed in response to the event.
Setting up Webhook
You need to have ssh_key from the server and save it in GitHub.
Go to the code repository and navigate to the settings. Then provide the details in Webhook section.
The payload URL is the Jenkins URL.
It should be configured now.
Automating Task-1 through Webhook
Make changes to the file in GitHub for the project and commit it.
Monitor the build in Jenkins that must have triggered automatically by webhook.
Navigate to the URL to see the changes that you had made in the code in GitHub.
Task-2 : Configuring Task-1 using Docker-Compose
Write a Docker Compose file for the application.
Now, go to Jenkins and navigate to the build steps of the project.
Now, build the project and check if the build is successfully completed. Finally navigate to the URL.
Thanks for reading my article. Have a nice day.
You can follow me on LinkedIn for my daily updates:- linkedin.com/in/bandan-kumar-sahoo-131412203