This is a simple notes app built with React and Django.
- Python 3.9
- Node.js
- React
- Clone the repository
git clone https://github.com/LondheShubham153/django-notes-app.git
- Build the app
docker build -t notes-app .
- Run the app
docker run -d -p 8000:8000 notes-app:latest
apt install docker-compose- add your user to the Docker group
sudo usermod -aG docker $USER- Add Jenkins User to Docker Group:
sudo usermod -aG docker jenkins
sudo systemctl restart jenkins
groups jenkinsIt looks like you mistyped the command. Instead of dicker, you should use docker. Here's the corrected command:
docker build -t notes-app .Make sure you have Docker installed and running on your system. If you encounter any issues with Docker, you can check the Docker service status:
sudo systemctl status dockerIf Docker is not installed, you can install it using:
sudo apt update
sudo apt install docker.ioOnce installed, you can start the Docker service and enable it to start on boot:
sudo systemctl start docker
sudo systemctl enable dockersudo apt-get update
sudo apt-get install fontconfig openjdk-17-jre
sudo apt-get install jenkins- This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system (for the Weekly Release Line):
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key- Then add a Jenkins apt repository entry:
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null- Update your local package index, then finally install Jenkins:
sudo apt-get update
sudo apt-get install fontconfig openjdk-17-jre
sudo apt-get install jenkins- The apt packages were signed using this key:
pub rsa4096 2023-03-27 [SC] [expires: 2026-03-26]
63667EE74BBA1F0A08A698725BA31D57EF5975CA
uid Jenkins Project
sub rsa4096 2023-03-27 [E] [expires: 2026-03-26]- step -1
Create AWS account - step 2
Create EC2 instance - step 3
Select - Amazon Machine Image (AMI) - UBUNTU Create new key pair - login for SSH local terminal - step 4
git clone Github-project-link cd - Enter you project directory sudo apt-get update - step 5
sudo apt-get docker.io docker --version give permission to not use "sudo docker" - sudo usermod -aG docker $USER sudo reboot - step 6
Again access with SSH key docker build -t notes-app . - step 7
install java sudo apt update sudo apt install openjdk-17-jre - step 8
install jenkins follow the link - https://pkg.jenkins.io/debian-stable/
service jenkins status
sudo usermod -aG docker jenkins
sudo systemctl restart jenkins
groups jenkins- step 9
open jenkins on browser copy public-ip from EC2 like http://3.110.207.109:8080/ jenkins port is 8080 EC2 instance in security gruop allow 8080 on your ip Now user password and start jenkins - step 10
After open jenkins select new-item and select pipelines Enter an item name "choose yours" - notes-app-cicd - step 11
select - GitHub project add links of git project in "Advanced" write "Display name" - step 12
Declarative pipeline write scrip in groovy language This is scriptIf you want to push image on docker hub make jenkins system global credentials docker hub username and password contein
pipeline {
agent any
stages {
stage('cloning Code') {
steps {
echo 'Cloning the code'
git url:'https://github.com/HackBugs/django-notes-app.git', branch: 'main'
}
}
stage('Build') {
steps {
echo 'Building the code'
sh 'docker build -t my-notes-app .'
}
}
stage('Push to Docker Hub') {
steps {
echo 'Push the image to Docker Hub'
withCredentials([usernamePassword(credentialsId:"dockerHub" ,passwordVariable:"dockerHubPass", usernameVariable:"dockerHubUser")]){
sh "docker tag my-notes-app ${env.dockerHubUser}/my-notes-app:latest"
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}"
sh "docker push ${env.dockerHubUser}/my-notes-app:latest"
}
}
}
stage('Deploy') {
steps {
echo 'Deploying the container'
sh "docker run -d -p 8000:8000 hackbugs/my-notes-app:latest" /*"docker-compose down && docker-compose up -d"*/
}
}
}
}- step 13
"docker login" on your EC2 terminal
Username - of DockerHub
Password - of DockerHub- step 14
install docker composecmd - sudo apt-get install docker-composedocker-compose up -ddocker-compose down - step 15
Also can direct groovy script can write in jinkins project in configruationcreate groovy script in you git roject - and select in jenkins configruation - Pipeline script from SCM use groovy file name and location - step 16
Everytime after changing in code not need to click in jenkins on "Build Now"webhook steup inside github settinggithub option "payload URL" paste your jenkins usr like ip port which you using to access of jenkinslike this - http://3.110.207.109:8080/github-webhook
- Pipeline
- Pipeline script - in this we write groovy code
- Pipeline script from SCM - in this groovy upload on github and set the path
☑️CICD Pipeline Jenkins without java we can't run jenkins before installing jenkins first install java
Setups-Download-git,Downlaod-Java,Download-Apache-Maven,Downlaod-Jenkins
continus Build + continus teat
- CICD Mean you are writing code on your vscode and pushing on git and you can see on your sever means your web-application something has been changed in between this things possible to happed due to jenkind
-
Developer (Code - Commit)
- The developer writes the code and commits it to a version control system (Git).
-
Git
- The committed code is pushed to a remote repository hosted on Git.
-
Jenkins
- Jenkins detects the new commit and triggers the CI/CD pipeline.
-
Pipeline Stages:
-
Commit
- The pipeline is triggered by the code commit.
-
Build
- Jenkins builds the application using tools like Maven, Gradle, or other build tools.
-
Test
- The application undergoes automated testing (unit tests, integration tests, etc.).
-
Stage
- The application is staged for deployment, preparing it for production. This may include further testing in a staging environment.
-
Deploy
- The application is deployed to the production environment.
-
-
Production
- The application is live and accessible to users.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
sh 'mvn clean install' // Replace with your build command
}
}
stage('Test') {
steps {
echo 'Testing...'
sh 'mvn test' // Replace with your test command
}
}
stage('Stage') {
steps {
echo 'Staging...'
// Add your staging steps here
// For example, deploying to a staging environment
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
// Add your deploy steps here
// For example, deploying to production
}
}
}
}- This script represents the pipeline shown in the image, with stages for build, test, stage, and deploy, running within Jenkins as part of a CI/CD process.
- jenkins is a framework and jenkins architecture is master-slave one master distribute task with slaves
- ➡️ Developer ➡️ Github ➡️ Jenkins ➡️ Mavan for Build ➡️ selenium for Test ➡️ checkstyle for QA ➡️ deployment and delivery - delivery mean after building and test we give the project of client and deployment means we build test and deployment
- ➡️ Maven ➡️ compile ➡️ code-review ➡️ unit-testing ➡️ intigration-testing ➡️ Packaging - war, jar
Sure, here is a list of Jenkins plugins that you mentioned, which can be installed by default to extend its functionality:
- Folders - Organize jobs into hierarchical folders.
- OWASP Markup Formatter - Provides security markup formatter for Jenkins.
- Build Timeout - Configures build timeouts.
- Credentials Binding - Allows credentials to be bound to environment variables.
- Timestamper - Adds timestamps to the Console Output.
- Workspace Cleanup - Cleans up the workspace before or after a build.
- Ant - Integrates Apache Ant.
- Gradle - Integrates Gradle.
- Pipeline - Supports building continuous delivery pipelines.
- GitHub Branch Source - Adds GitHub Branch as a source for multi-branch Pipeline.
- Pipeline: GitHub - Integrates GitHub with Jenkins Pipeline.
- Groovy Libraries - Loads Groovy libraries for Jenkins Pipeline.
- Pipeline Graph View - Visualizes Jenkins Pipeline jobs.
- Git - Integrates Git with Jenkins.
- SSH Build Agents - Adds SSH build agents for Jenkins.
- Matrix Authorization Strategy - Provides matrix-based security authorization.
- PAM Authentication - Integrates PAM (Pluggable Authentication Modules) for authentication.
- LDAP - Integrates LDAP for authentication.
- Email Extension - Provides extended email notification functionality.
- Mailer - Sends email notifications.
- Dark Theme - Adds a dark theme to Jenkins for a better visual experience.
To install these plugins, follow these steps:
-
Access Jenkins Plugin Manager:
- Open Jenkins.
- Go to "Manage Jenkins" > "Manage Plugins".
-
Install Plugins:
- Search for each plugin name listed above.
- Check the box next to each plugin.
- Click on "Install without restart" or "Download now and install after restart".
Alternatively, you can use the Jenkins CLI to install these plugins. Below is a script to install all the listed plugins using the Jenkins CLI:
# Download Jenkins CLI
wget http://localhost:8080/jnlpJars/jenkins-cli.jar
# Define Jenkins URL and credentials
JENKINS_URL=http://localhost:8080
JENKINS_USER=your_username
JENKINS_PASSWORD=your_password
# Install plugins
java -jar jenkins-cli.jar -s $JENKINS_URL -auth $JENKINS_USER:$JENKINS_PASSWORD install-plugin \
cloudbees-folder \
antisamy-markup-formatter \
build-timeout \
credentials-binding \
timestamper \
ws-cleanup \
ant \
gradle \
workflow-aggregator \
github-branch-source \
pipeline-github \
pipeline-groovy-lib \
pipeline-graph-analysis \
git \
ssh-slaves \
matrix-auth \
pam-auth \
ldap \
email-ext \
mailer \
dark-theme
# Restart Jenkins to apply changes
java -jar jenkins-cli.jar -s $JENKINS_URL -auth $JENKINS_USER:$JENKINS_PASSWORD safe-restartReplace your_username and your_password with your Jenkins credentials. Run this script in your terminal to install the plugins and restart Jenkins.
- This list ensures you have a robust Jenkins setup with essential plugins for various functionalities, enhancing your CI/CD pipeline.
-
Jenkins Plugin Install
- Maven intigration
- Green Balls
-
Jenkins Global Tool Configuration - we can set like environment variables path in jenkins inside Global Tool Configuration
-
Pull project form github - PS C:> git clone https://github.com/HackBugs/time-tracker.git
-
cd C:> cd .\time-tracker\
-
CMD Of Maven - mvn clean package