Repository navigation
Expand file tree
/
Copy pathbash devops.txt
More file actions
194 lines (128 loc) · 3.5 KB
/
Copy pathbash devops.txt
File metadata and controls
194 lines (128 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
1. Perform GIT operations on local remote repositories. (Create Repository, add files. Commit changes, pushing objects to remote repository)
mkdir filename
cd filename
git init
nano filename2.txt
git status
git add filename2.txt
git commit -m "Initial commit Added by me"
git remote add origin <GitHub link>
git push -u origin master
2. Perform GIT operations on local remote repositories.(Create Repository, add files, create branches, switch between branches)
mkdir filename
cd filename
git init
nano filename2.txt
git add .
git commit -m "This is first commit"
git branch branch1
git branch
git checkout branch1
git branch
git switch master
git branch
3. Perform GIT operations on Remote repositories (Create Repository, add files. Commit changes, cloning, pulling and pushing objects)
git clone <GitHub link>
mkdir filename
cd filename
git init
nano filename2.txt
git add .
git commit -m "Initial commit"
git push -u origin main
git pull origin main
4. Build the Java jobs using in Jenkins
Build the Java Job using Jenkins
Step 1:
Create a Java file → sample.java
public class sample {
public static void main(String[] args) {
System.out.println("Hello Java in Jenkins!");
}
}
Step 2:
Open Jenkins → http://localhost:8080/
Step 3:
New Item → Freestyle Project → give name: JavaJob
Step 4:
Go to Build → Add build step → Execute Windows batch command
Type:
javac sample.java
java sample
Step 5:
Click Save → Build Now
Step 6:
Check Console Output → you should see:
Hello Java in Jenkins!
5. Build the python jobs using in Jenkins
Step 1:
Create Python file → sample.py
print("Hello Python in Jenkins!")
Step 2:
New Item → Freestyle Project → give name: PythonJob
Step 3:
Go to Build → Add build step → Execute Windows batch command
Type:
python sample.py
Step 4:
Click Save → Build Now
Step 5:
Check Console Output → you should see:
Hello Python in Jenkins!
6. Crete a simple pipeline script using Jenkins
Step 1:
pipeline {
agent any
stages {
stage('Git Checkout') {
steps {
git branch: 'main', url: 'https://github.com/ganeshghutukade-04/gitdemo.git'
}
}
stage('Build Java') {
steps {
script {
if (fileExists('sample.java')) {
bat 'javac sample.java'
bat 'java sample'
} else {
echo 'No Java file found.'
}
}
}
}
stage('Run Python') {
steps {
script {
if (fileExists('sample.py')) {
bat 'python sample.py'
} else {
echo 'No Python file found.'
}
}
}
}
}
post {
success {
echo 'Pipeline completed successfully!'
}
failure {
echo 'Pipeline failed. Check errors above.'
}
}
}
Step 3:
Click Save → Build Now
Step 4:
Check Console Output → output from both Java and Python programs will appear (if files exist).
7. docker
docker version
docker info
docker images
docker image ls
docker ps
docker ps -a
docker pull ubuntu
docker inspect ubuntu
docker rmi ubuntu