Skip to content

Commit 886c1a2

Browse files
committed
setup ci/cd pipeline using jenkins
1 parent 4e6ce1e commit 886c1a2

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

  • Setting up Ci/CD pipeline using jenkins
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Jenkins CI/CD Setup Guide
2+
3+
Whether you're new to Jenkins or looking to set up a CI/CD pipeline on your server, this comprehensive guide will help you through clear, step-by-step instructions.
4+
5+
## Pre-requisites
6+
7+
- Ubuntu OS (Xenial or later)
8+
- sudo privileges
9+
- Internet access
10+
- t2.medium instance type or higher
11+
12+
---
13+
14+
# Execute all the command step by step
15+
16+
## Install Jenkins
17+
18+
1. **Update your system**:
19+
20+
```bash
21+
sudo apt update
22+
sudo apt upgrade -y
23+
24+
2. **Install Java**:
25+
```bash
26+
sudo apt install openjdk-11-jdk -y
27+
28+
3. **Add Jenkins repository**:
29+
```bash
30+
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
31+
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
32+
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
33+
https://pkg.jenkins.io/debian binary/ | sudo tee \
34+
/etc/apt/sources.list.d/jenkins.list > /dev/null
35+
36+
4. **Install Jenkins**:
37+
```bash
38+
sudo apt update
39+
sudo apt install jenkins -y
40+
41+
5. **Start Jenkins service**:
42+
```bash
43+
sudo systemctl start jenkins
44+
sudo systemctl enable jenkins
45+
46+
6. **Access Jenkins**:
47+
>Open a web browser and go to http://<your-server-ip>:8080.
48+
>Unlock Jenkins by copying the password from the initialAdminPassword file:
49+
```bash
50+
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
51+
52+
# Configure Jenkins
53+
54+
- **Install suggested plugins** during the initial setup.
55+
- **Create an Admin User**:
56+
- Follow the on-screen instructions to create your admin user.
57+
- **Configure Jenkins URL**:
58+
- Set the Jenkins URL to your server's IP address or domain name.
59+
60+
# Set Up a Jenkins Job
61+
62+
## Create a New Job:
63+
64+
1. Go to Jenkins Dashboard.
65+
2. Click on `New Item`.
66+
3. Enter a name for your job and select `Pipeline`. Click `OK`.
67+
68+
## Configure the Pipeline:
69+
70+
1. In the job configuration page, scroll down to the `Pipeline` section.
71+
2. Select `Pipeline script from SCM`.
72+
3. Choose `Git` and enter your repository URL.
73+
4. Specify the branch to build (e.g., `main`).
74+
75+
# Create a Jenkinsfile
76+
77+
Create a `Jenkinsfile` in the root of your repository with the following content:
78+
79+
```groovy
80+
pipeline {
81+
agent any
82+
83+
stages {
84+
stage('Build') {
85+
steps {
86+
echo 'Building...'
87+
// Add build steps here
88+
}
89+
}
90+
stage('Test') {
91+
steps {
92+
echo 'Testing...'
93+
// Add test steps here
94+
}
95+
}
96+
stage('Deploy') {
97+
steps {
98+
echo 'Deploying...'
99+
// Add deploy steps here
100+
}
101+
}
102+
}
103+
104+
post {
105+
always {
106+
echo 'Cleaning up...'
107+
// Add cleanup steps here
108+
}
109+
}
110+
}
111+
112+
```
113+
# Run the Pipeline
114+
115+
## Trigger the Pipeline:
116+
- Go to your job in Jenkins.
117+
- Click `Build Now` to trigger the pipeline.
118+
119+
## Monitor the Build:
120+
- Click on the build number to see the build details.
121+
- Check the console output for logs and debug information.
122+
123+
# Troubleshooting
124+
125+
## Common Issues
126+
127+
- **Jenkins not starting**: Check Jenkins logs for errors:
128+
```bash
129+
sudo journalctl -u jenkins
130+
131+
132+
***Using all these processes, you will successfully set up a CI/CD pipeline using Jenkins. Now you can enjoy automating your build, test, and deployment processes, and if you are facing any issues, please don't hesitate to ask me. You can connect with me on:***
133+
134+
- [LinkedIn](https://www.linkedin.com/in/v-litesh-kumar-2094b5218)
135+
- [Mail Me](mailto:kvlitesh@gmail.com)
136+
137+
Let's dive into Jenkins together and streamline your software delivery!
138+
139+
**Happy CI/CD-ing!** 🚀
140+
141+
142+
143+

0 commit comments

Comments
 (0)