forked from Harshavardhanreddie/Devops-interview-QA
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkins interview QA.txt
638 lines (493 loc) · 25.4 KB
/
Jenkins interview QA.txt
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
1 * Explain CI/CD -- answer from rangaswamy sir
As soon as developer pushes code to github. Jenkins pipeline job will get triggered, it has three stages, Build, Deploy and test stages.
In build stage, It will pull source code from github, compiles it and generates binary. Once build stage is success, deploy stage will get triggered
It will deploy war file tom tomcat server and run BVT. Next,test stage will get triggered, it runs test cases given by test team.
if there are any test failures will be taken care by testing team. if there are any integration issues , it will be taken care by dev team.
(OR)
As soon as a developer pushes the code, the code is reviewed by reviewer {Gerrit tool can be used to perform the code review} and then commit is performed, once a new commit occurs, it triggers a Jenkins job.
Jenkins job consists of mainly 3 stages: Build, Deploy and Test stage
A webhook tells the CI/CD tool which commit triggers the pipeline, which checks out the source code at the appropriate commit point
Build stage à CI/CD tool needs a build tool ( Maven (or) Gradel ), here it will pull the source code from GitHub, compiles it and generates binary, once build stage is success , Deploy stage is triggered
Deploy state à It will deploy a war file (web archive file) from tomcat server and run BVT (build verification test)
Once BVT is successful, it will then move on to next phase, Test phase
Test Phase à Here test cases are run as provided by test team (sonarcube is used to validate the quality of the code)
If any test failures then it will be checked by testing team, if there are any integration issue, it will be checked by development team
Post which artifacts are passed into JFrog artifatory, from there UAT (User acceptance test) is performed, Selenium (or) cucumber can be used to perform the acceptance test.
2 * How u setup cicd for these different features like u maintain separate jobs for separate feature branches
Pipeline Job - jenkins file, write groovy code
3 * 1 feature has 50 components how u test that in ur pipeline
Don't know
4 * Declarative pipeline? What all the components in it ?
Pipeline script with SCM
Pipeline block
Agent
Stages
Stage
Steps
5 * Shared Libraries ?
Jenkins shared library is the concept of having common pipeline code in the version control system that can be used by any number of pipelines just by referring it.
Eg – if we have 10 java micro services pipelines the maven build step will be duplicated in all 10 pipelines. On addition of new services, we have to copy paste pipeline code again. If we want to change some parameter we will need to do it in all the pipelines manually.
When we use the shared library all the common code is kept there and if we update the code there it will appear in all the 10 pipelines.
Jenkins shared library
1. vars – This directory holds all the global shared library code that can be called from a pipeline. It has all the library files with .groovy extn.
2. src – It’s a regular java source directory. It is added to the class path during every script compilation. Here we can add the custom groovy code to extend the shared library code.
3. Resources – all the non-groovy files required for the pipeline can be managed from here. Like jenkinsfile, xml etc.
6 * When to use free style and pipeline job
Free style job -- for Single purpose project
Pipeline job - To run multiple tasks which are independent/dependent in an automated way
7 * Is it possible that one stage fails and continue the execution to next stage ?
Option present in Build trigger
Build after other projects are built
8 * Write a jenkinsfile which pull the code from git repo and push the jar file to AWS S3?
(This jenkins file shd work on all environments)
10 * In Jenkins, do you know how to write custom functions in groovy?
Yes -- pipeline block (agents, stages) -- need to practice
16 * sonarqube integration
Qualitygate plugin
17 * what are the jenkins plugin have you used
Ssh, parameterized, gearman, maven, github, sonarcube, blueocean
Also explain why these plugins are used
Gearman - Creates a backup jenkins prod server, so when primary server is down, jenkins services are available via secondary server
Maven - to integrate builds
Sonarcube - To integrate testing of code
BlueOcean - Integrate dashboard, which allows us to create a pipeline and see through it
19 * webhooks
It is a mechanism to automatically trigger the build of a jenkins project upon a commit is pushed in a Git repository
Need to make sure that we have GitHub plugin installed on Jenkins server
On Project --> Source Code Management --> select Git --> Give Repository URL
Enable "GItHub hook trigger for GITScm Polling" and "Poll SCM"
On GitHUb --> Settings --> WebHook--> Add webhook --> Payload URL (your repo link)--> Content type 'application/json' --> which even should trigger this webhook 'Just the push even' --> add webhook
21 how to send email notification to jenkins
Dashboard --> Manage Jenkins --> Configure System --> Extended E-mail Notification
Maven Build command in java - DO not know
We have to run "maven clean package" from where ever we have our project/files but after that steps are longer and need to be practiced and done to explain
21 * how to take backup of jenkinfile
Clone the Jenkins home directory/installation folder and then push to GitHub repository
23 * How you schedule builds
Build Trigger periodically
24 * How you have integrated each tool in CiCd explain configuration
Yes, Docker, Sonarcube, BlueOcean, TinyBackup
25 * Explain jenkinsfile
File containing declarative script in groovy
This file contains the configuration to run the pipeline
Script is written within the pipeline block
36 * Pipeline with stage 1 n stage2, calculate a value of a variable in stage 1 and pass that value in stage2.
Declarative script in groovy
Example script::
pipeline {
agent
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}
37 * how can i share the value btn two stages in pipeline?
Using Declarative script in groovy
Example script::
pipeline {
agent
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}
38 * Have you created any pipeline and type of pipeline ?
Yes, explain Pipeline job , creation of pipeline job
Pipeline --> pipeline script and Pipeline script with SCM
Also give example declarative script (or) pipeline script
39 * Explain about the diff stages of pipeline
Explain about Build, Deploy, Test
40 * Which artifactory are you using ?
Jfrog artifactory -- Need to collect info on Jfrog
41 * Explain about agents ?
Agents define the execution scope of the stage
(or)
specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed
42 * Have you created dynamic agents
Need to check, if it is similar to Agents any (or) none
43 * Jenkins Code as a Service?
Using pipeline script with SCM --> Jenkins file in groovy script, this is what Jenkins Code as a Service will be
45 * If you want to write something new thing in Declarative script which you don’t know, how you will be doing it?
We would go to pipeline syntax --> Snippet generator (or) Declarative Directive Generator
46 * Feature Flag in CICD
is a technique that will help you integrate code into a shared repository at least once a day and ship it, even if you haven't finished the feature yet.
58 * U have some issues in applications in Jenkins how will u find out
/var/log/jenkins
60 * Deployment strategies
Blue-Green deployment
Canary Deployment
Rolling deployment
Shadow deployment
63 * what is that you use in Jenkins for ensure all the integration part and test part
Maven for build, Jenkins Pipeline for integration, Sonarcube for integration testing, selenium for blackbox testing (part of UAT)
64 * what are the plugins you are using for cicd setup in current company
○ BlueOcean
○ Gearman
○ Git integration
○ GitHub
○ Parameterized
○ Role-based authorization stratergy
○ Maven
○ Quality gates (sonarcube)
○ Selenium RC and Selenium Builder
○ docker
65 * what kind of environment you created for Jenkins cicd setup
○ QA
○ Dev
○ UAT
○ Prod
71 * Parallel block inside stage
Build and Test are happening parallel in the below pipeline block
pipeline {
agent { label 'master' }
stages {
stage('Both build and test') {
parallel {
stage('Build') {
steps {
sh 'sleep 15; echo "This is a Build stage"'
}
}
stage('Test'){
steps {
sh '''
sleep 15
echo "This is a Test stage"
'''
git branch: 'main', url: 'https://github.com/jaintpharsha/devops-jan-22.git'
}
}
72 * how to send email notification to jenkins
Post build actions --> Editable email notification
73 * what is the deployment strategy that is used in ur company and other stratgies that u know?
Blue-Green deployment
Canary Deployment
Rolling deployment
Shadow deployment
76 * How are u managing the code quality of ur application.
Code quality is managed via Sonarcube
86 * Benefits of Blue green deployment?
https://www.flagship.io/blue-green-deployment-pros-and-cons/
Rapid Releasing
Simple Rollbacks
Built in disaster recovery
Load balancing
93 * When to use free style and pipeline job
Freestyle project à is for more simple tasks, we cannot use freestyle project for multiple jobs and complex tasks
Pipeline Project à We use this to create multiple jobs which may/may not be independent to achieve a release in an automated manner
With pipeline project we have more control, you can choose which stage of the pipeline can be used in which manner
95 * when there is no internet connection can you install jenkins
If you have downloaded the dependencies and the Jenkins installation package, then yes, you can install Jenkins without internet
96 * no backup & installed lot of plugins & jobs. now installed one more plugin and crashed my whole jenkins. now ui is down..how do you uninstall plugins.
Go to à /var/lib/jenknis/plugin and then remove the plugin binary ( *.hpi (or) *.jpi ) and the folder from the location
97 * difference between freestyle & pipeline job
Freestyle project à is for more simple tasks, we cannot use freestyle project for multiple jobs and complex tasks
Pipeline Project à We use this to create multiple jobs which may/may not be independent to achieve a release in an automated manner
With pipeline project we have more control, you can choose which stage of the pipeline can be used in which manner
98 * which you can't do in freestyle. which can be done pipeline technical difference
With pipeline project we have more control, you can choose which stage of the pipeline can be used in which manner
100* pipeline syntax
Declarative script in groovy
Example script::
pipeline {
agent
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}
101* which pipeline you are using in your company
Multibranch pipeline, pipeline script with SCM
102* custom build of a core plugin
-- Question can be rephrased as -- how to install/unisntall plugin without Jenkins GUI
Stop jenkins process
Download the .hpi/.jpi plugin and save it to /var/lib/jenkins/plugin folder (or) Jenkins_home directory plugins folder
103* have you are checked code quality
Yes, via Sonarcube , by integrating qualitygates plugin on Jenkins
104* process to integrate git with jenkins
--> Install the GitHUb Plugin, GitHub API, GitHub Client, GitHub BranchSourceCode plugin
--> Create a Jenkins project
Go to--> Source Code Management --> Git
Enter --> Repository URL and credentials
106* whats the use of pom.xml file
==> POM.xml is a xml file, which contains the project details along with configuration information which is used by Maven to perform builds
==> When "maven install" is done, maven creates a dependency tree based on the information from PO.xml and then downloads/compiles all the needed components into a directory ".m2" under the user's fodler
107* maven build lifecycle
Maven Lifecycle steps
----------------------
Validate --> If project is correct and has all necessary information
Compile --> Compile the source code of the project
Test --> Test the source code without packaging (or) deploying it, using a unit testing framework
Package --> Package the source code into .jar, which is the distributed format
Integration Test --> Testing of various software modules as a group
Verify --> Check the results of integration testing and ensure quality is met
Install --> Install the package into local repository
Deploy --> Copies final package to remote repository for sharing with other developers done in build env
112* why do we need continuous integration and continuous deployment in jenkins, what are the advantages.
CI - You need CI so the developers can get immediate feedback on their code quality and build
CD - Once the code is build, tested successfully, It can be pushed to the production environment
There is a continuous feedback loop on the code builds and testing which is being done
113* How to select slaves in jenkins file
using agent none and assigning the label, so the specific stage can be run on specific agent (slave agent)
115* How webhook triggers
• Need to make sure that we have GitHub plugin installed on Jenkins server
• On Project --> Source Code Management --> select Git --> Give Repository URL
• Enable "GItHub hook trigger for GITScm Polling" and "Poll SCM"
• On GitHUb --> Settings --> WebHook--> Add webhook --> Payload URL (your repo link)/git-webhook --> Content type 'application/json' --> which even should trigger this webhook 'Just the push even' --> add webhook
116* How authentication of Jenkins and git is done
Jenkins authentication
○ Matrix based security
○ Project based matrix authorization stratergy
○ Role based authentication/strategy -- need to install plugin for this
By saving the credentials in Git Credential storage --> https://www.shellhacks.com/git-config-username-password-store-credentials/
Git Credentials binding plugin on jenkins
Here we can give Git username and password
117* What kind of credentials used - same as previous question
118* What build tool ? how build happen?
Build Tools ==> Maven, Make, Gradel
Explain Maven Lifecycle
Maven Lifecycle steps
Validate --> If project is correct and has all necessary information
Compile --> Compile the source code of the project
Test --> Test the source code without packaging (or) deploying it, using a unit testing framework
Package --> Package the source code into .jar, which is the distributed format
Integration Test --> Testing of various software modules as a group
Verify --> Check the results of integration testing and ensure quality is met
Install --> Install the package into local repository
Deploy --> Copies final package to remote repository for sharing with other developers done in build env
make---
ABC.exe:output.o search.o sort.o input.o
gcc -o ABC.exe output.o search.o sort.o input.o
output.o:output.c
gcc -c output.c
search.o:search.c
gcc -c search.c
sort.o:sort.c
gcc -c sort.c
input.o:input.c
gcc -c input.c
124* CICD set up
CI/CD pipeline, Jenkins configuration , Multibranch pipeline/pipeline script with SCM
125* Difference between CI and CD
CI - continuous integration
Integrating changes from development team without manual intervention and giving immediate feedback to the development team
CD -- Continuous Delivery
Testing the changes immediately post pushing of code by development team
CD -- Continuous Deployment
Deploying to production environment post testing
126* Branching strategies means git work flows
Feature Branching
Releasing branching
131* Tomcat troubleshooting steps
Check if the tomcat service is running (or) not
Sudo systemctl tomcat status
Sudo systemctl tomcat start
If it fails to start then check the logs
/var/log/messages
133* Where is jenkins set up
On-premise (or) Containers (or) Cloud
138* In maven, explain how you download dependencies
"maven build" --> this command is run, it downloads all the dependency jars into the local repository
So basically maven will check pom.xml file and check for the jar file information and then download the dependency to the local repository accordingly
140* Explain your deployment strategy
Choose any one and explain in details
○ Blue-Green deployment
○ Canary Deployment
○ Rolling deployment
○ Shadow deployment
141* I want two stages to execute at a time in jenkins, can I do that... How?
Using Jenkins file by utilizing parallel script
Example::
Jenkins Parallel script
pipeline {
agent { label 'master' }
stages {
stage('Both build and test') {
parallel {
stage('Build') {
steps {
sh 'sleep 15; echo "This is a Build stage"'
}
}
stage('Test'){
steps {
sh '''
sleep 15
echo "This is a Test stage"
'''
git branch: 'main', url: 'https://github.com/jaintpharsha/devops-jan-22.git'
}
}
}
}
stage('Deploy'){
steps {
sh '''
sleep 5
echo "This is a Deploy stage"
'''
}
}
stage('My-stage'){
steps {
sh '''
sleep 5
echo "This is a My-stage stage"
'''
}
}
}
}
142* I want to select particular version for build, how can i do that during CI CD
==> Jenkins project # tag build version, we chose the build version from there
(or)
==> Jenkins file, pipeline script, node information
146* How you configured webhooks, which URL you used there
Jenkins Payload URL
149* if your jenkins agents are setup for 20 build capacity, and suddenly 50 builds comes in how will you handle the situation?
○ Need to install the Amazon EC2 plugin in Jenkins
○ Manage Jenkins --> Configure System --> Cloud section --> Add a new cloud button --> Select "Amazon EC2" option
Check the link for further understanding ==> https://plugins.jenkins.io/ec2/
○ So this will provide Jenkins with option of identifying cluster overload and deploy ec2 instances with Jenkins agents on them, once the cluster load is reduced , then it will delete the ec2 instnaces
153* which instance type u r using for jenkins master, its details
Amazon ec2 ==> c4.large, c4.xlarge
156* explain stages in cicd
Build, Deploy, Test
158* how your implementing QA in your cicd
By integrating Sonarcube and selenium in Jenkins
Installing Quality Gates in sonarcube and also selenium plugins
161* multibranch pipeline ?
The Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different branches of the same project.
In a Multibranch Pipeline project, Jenkins automatically discovers, manages and executes Pipelines for branches which contain a Jenkinsfile in source control.
162* How to setup multiple Java or Maven or Git versions in Jenkins server?
Manage Jenkins --> Global Tool configuration --> install the tool versions accordingly
============================================Discussed with Harsha sir==================================================
1) Jenkins is building on dev branch and someone else is pushing the code, but the build is in progress. If someone pushes the code, it triggers another build, so what will u do to stop the parallel build?
Declarative Script
pipeline {
options {
disableConcurrentBuilds()
}
}
Scripted
node {
properties([disableConcurrentBuilds()])
}
2) How do you disable it in groovy script?(continue from above question)
Declarative Script
pipeline {
options {
disableConcurrentBuilds()
}
}
Scripted
node {
properties([disableConcurrentBuilds()])
}
---by default groovy is serial execution
3) How frequently u release a new feature ? -- confirm the answer
Based on the application/project
There are major release and minor release
Major updates may be quarterly (or) yearly depending on the application and project that we are associated with
For test environment we release it frequently and it is deployed immediate, since we have a pipeline created
4) when we use process of creating multibranch pipeline in jenkins ?
its depending upon the project most of the cases we won't use it
if it's require to build for all banches for every commit to all baranches then we use it.
5) how do you use function in groovy script?
@Library('Shared library') _
greetUser 'USERNAME' 'DESIG'
6) how will set the quality gates in sonar qube and how will you check quality of source code
go for any video in youtube for better clarification--jfrog xray,sonarqube,sonar runner,sonar scanner
https://www.youtube.com/watch?v=Spzk1lrCgNY
7) How you will do insights and analysis of your CICD?
will identify the tools stack (or) technology--ex:maven
communicate with dev team,will get to know what we have to buld so that
we can decide how many stages are required including test automation.
8) I have a jenkins pipeline where sonarqube is integrated with quality gates. But if the code doesnt passes through quality gates how will you fail the build and stop it from creating artifacts.?
https://www.youtube.com/watch?v=Spzk1lrCgNY
9) explain your Jenkins setup like how many slaves you are maintaining
Multi-master cluster
Minimum 3 master
We setup via either AWS (or) Kubernetes
Based on available computer resources,we can have 12 slaves
In our company we have around 400-500 builds depending upon the teams, we have around 10 slaves
For testing builds, where we can go upto 800 builds, we can stretch our slaves upto 12, also we do have process to have slaves spinned up when required
10) Real life scenarios on Canary deployment?
harsha sir will explain in k8's
11) What is the default deployment strategy?
k8's
12) Is it possible that one stage fails and continue the execution to next stage ?
yes,using try catch block
stage('build'){
steps {
sh echo'if this build will fails'
}
}
stage('NAME') {
steps {
catchError(busildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "exit 1"
}
}
}
13) jenkins build failures
14) how to deploy an application from jenkins to k8s -- Kubernetes topic
helm charts
15) CICD jenkins have you build any pipeline , in process approval in jenkins. detect that failure in deployment time and commands to use to reverse the build.
yes,if the build fails will deploy previous build(roll out)
16) Jenkins is on premise ?
No,we are using AWS so jenkins server runs on AWS.
17) I want to select particular version for build, how can i do that during CI CD ? -- confirm below answer
use parameterised build (or) job
18) which tests you perform in ci cd ? (or) what are the diffrent type of test u do in cicd? -- confirm below answer
Integration test, sanity test, UAT etc…
19) how you have deployed to production explain the procedure?
once ECAB apporves we have a job which is not automated,we manually run the job for prod env
20) How you automate complete cicd ? -- Maybe after Kubernetes, please confirm
21)Pipeline with stage 1 n stage2, calculate a value of a variable in stage 1 and pass that value in stage2?
pipeline {
agent {
label '!windows'
}
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}