DevOps Interview Basic and Chef Puppet
DevOps Interview Basic and Chef Puppet
Maven
Manage Jenkinks→ Global Tool Configuration→ Maven Installations→ Add Maven
1|P AG E
Jenkins Architecture
Jenkins Master
Your main Jenkins server is the Master. The Master’s job is to handle:
Scheduling build jobs.
Dispatching builds to the slaves for the actual execution.
Monitor the slaves (possibly taking them online and offline as required).
Recording and presenting the build results.
A Master instance of Jenkins can also execute build jobs directly.
Jenkins Slave
A Slave is a Java executable that runs on a remote machine. Following are the characteristics of Jenkins Slaves:
It hears requests from the Jenkins Master instance.
Slaves can run on a variety of operating systems.
The job of a Slave is to do as they are told to, which involves executing build jobs dispatched by the
Master.
You can configure a project to always run on a particular Slave machine, or a particular type of
Slave machine, or simply let Jenkins pick the next available Slave.
The diagram below is self-explanatory. It consists of a Jenkins Master which is managing three Jenkins Slave.
2|P AG E
Now let us look at an example in which Jenkins is used for testing in different environments like: Ubuntu, MAC,
Windows etc.The diagram below represents the same:
Jenkins checks the Git repository at periodic intervals for any changes made in the source code.
Each builds requires a different testing environment which is not possible for a single Jenkins
server. In order to perform testing in different environments Jenkins uses various Slaves as shown in
the diagram.
Jenkins Master requests these Slaves to perform testing and to generate test reports.
3|P AG E
Step 4) Enter the details of the project you want to test.
4|P AG E
Step 5) Under Source Code Management, Enter your repository URL. We have a test repository located
at https://github.com/kriru/firstJava.git
Step 6) Under build, Click on "Add build step", "Execute Windows batch command" and add the commands
you want to execute during the build process.
5|P AG E
Step 7) Click the Build Now button on the left-hand side to build the source code.
Step 9) After clicking on Build now, you can see the status of the build you run under Build History.
6|P AG E
Step 10) Click on the build number and then Click on console output to see the status of the build you run. It
should show you a success message, provided you have followed the setup properly.
In sum, we have executed a HelloWorld program hosted on GitHub. Jenkin pulls the code from the remote
repository and builds continuously at a frequency you define.
7|P AG E
Mention some of the useful plugins in Jenkins?
Below I have mentioned some important Plugins:
Maven 2 project
Git
Amazon EC2
HTML publisher
Copy artifact
Join
Green Balls
Mention what are the commands you can use to start Jenkins manually?
To start Jenkins manually open Console/Command line, then go to your Jenkins installation directory. Over there
you can use the below commands:
8|P AG E
Now you can tell the elements of this freestyle job:
Optional SCM, such as CVS or Subversion where your source code resides.
Some sort of build script that performs the build (ant, maven, shell script, batch file, etc.) where the real
work happens.
Optional steps to collect information out of the build, such as archiving the artifacts and/or recording
javadoc and test results.
Optional steps to notify other people/systems with the build result, such as sending e-mails, IMs,
updating issue tracker, etc..
To create a backup all you need to do is to periodically back up your JENKINS_HOME directory. This
contains all of your build jobs configurations, your slave node configurations, and your build history. To create a
back-up of your Jenkins setup, just copy this directory. You can also copy a job directory to clone or replicate a
job or rename the directory.
Explain how you can move or copy Jenkins from one server to another?
I will approach this task by copying the jobs directory from the old server to the new one. There are multiple
ways to do that, I have mentioned it below:
You can:
Move a job from one installation of Jenkins to another by simply copying the corresponding job
directory.
Make a copy of an existing job by making a clone of a job directory by a different name.
Rename an existing job by renaming a directory. Note that if you change a job name you will need to
change any other job that tries to call the renamed job.
What are the various ways in which build can be scheduled in Jenkins?
9|P AG E
What is the syntax Jenkins uses to schedule items such as build jobs and SVN polling?
Jenkins uses the cron syntax to schedule various items within the tool.
The cron syntax is represented by five asterisks(* * * * *), with each one separated by a space.
For example, to schedule a build job to pull from GitHub every Friday at 5:30 p.m., the syntax would be: 30
17 * * 4.
The Jenkins pipeline details are stored in a file that is named as the Jenkins file and it is further connected to the
source code repository in general.
stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
10 | P A G E
11 | P A G E
12 | P A G E
13 | P A G E
14 | P A G E