DevOps - Unit - 3.pptx
DevOps - Unit - 3.pptx
DevOps - Unit - 3.pptx
2. Buddy is another CI/CD tool used to build, test, and develop the software code. Buddy
was mainly designed for working on codes that are part of the Bitbucket and GitHub
repositories.
3. Apache Gump is written in Python. It builds and compiles software code against the
latest versions of projects.
8. GitLab CI is hosted on the free hosting service GitLab.com, and it offers a Git
repository management function with features such as access control, bug
tracking, and code reviewing.
11. Travis CI is an open-source CI service free for all open source projects hosted
on GitHub.
If you
translate
the steps
to a
Jenkins
pipeline
job, it
looks like
• Jenkins Plugins
• Plugins are the primary means of enhancing the functionality of a Jenkins
environment to suit organization- or user-specific needs.
• You can install/upgrade all the available plugins from the Jenkins
dashbaord itselft. For corporate net
Following are the key components in Jenkins
• When you trigger a Jenkins job from the master, the actual
execution happens on the agent node that is configured in the job.
• You can run jobs in the Jenkins server without a Jenkins agent. In
this case, master nodes acts as the agent.
• However, the recommended approach is to have a Jenkins
master-agent setup for different job requirements so that you don’t
end up corrupting the Jenkins server for any system-wide
configuration changes required for a job.
• You can have any number of Jenkins agents attached to a master
with a combination of Windows, Linux servers, and even containers
as build agents.
• Also, you can restrict jobs to run on specific agents, depending on
the use case.
• For example, if you have an agent with java 8 configurations, you
can assign this agent for jobs that require Java 8 environment.
• There is no single standard for using the agents.
• You can set up a workflow and strategy based on your project
needs.
• Jenkins Case Study
• Bosch (Jenkins CloudBees – to Improve efficiency – 3 day build
process reduced to less than 3 hours)
Jenkins Master-agent Connectivity
• You can connect a Jenkins master and agent in two ways
Using the SSH method: Uses the ssh protocol to connect to the agent.
• The connection gets initiated from the Jenkins master.
• Their should be connectivity over port 22 between master and agent.
Using the JNLP method: Uses java JNLP protocol (Java Network
Launch Protocol).
• In this method, a java agent gets initiated from the agent with Jenkins
master details.
• For this, the master nodes firewall should allow connectivity on
specified JNLP port.
• Typically the port assigned will be 50000. This value is configurable.
Jenkins Credentials
• When you set up Jenkins pipelines, there are scenarios where it
needs to connect to a cloud account, a server, a database, or an API
endpoint using secrets.
• In Jenkins, you can save different types of secrets as a credential.
1. Secret text
2. Username & password
3. SSH keys
• All credentials are encrypted (AES) by Jenkins.
• The secrets are stored in $JENKINS_HOME/secrets/ directory.
• It is very important to secure this directory and exclude it from
Jenkins backups.
• Jenkins Nodes/Clouds
• You can configure multiple agent nodes (Linux/Windows) or clouds
(docker, kubernetes) for executing Jenkins jobs.
Jenkins Global Settings (Configure System)
• Under Jenkins global configuration, you have all the configurations
of installed plugins and native Jenkins global configurations.
• Also, you can configure global environment variables under this
section.
• For example, you can store the tools (Nexus(store, distribute, and
retrieve build artifacts whenever it's required), Sonarqube(an
open-source tool for ongoing code quality inspection), etc) URLs as
global environment variables and use them in the pipeline.
• This way it is easier to make URL changes that get reflected in all
the Jenkins jobs.
• Jenkins Logs
• Provides logging information on all Jenkins server actions including
job logs, plugin logs,
There are two types of Jenkins agents
Agent Nodes
• These are servers (Windows/Linux) that will be configured as static
agents. These agents will be up and running all the time and stay
connected to the Jenkins server.
Agent Clouds:
• Jenkins Cloud agent is a concept of having dynamic agents.
• Means, whenever you trigger a job, a agent gets deployed as a
VM/container on demand and gets deleted once the job is
completed.
• This method saves money in terms of infra cost when you have a
huge Jenkins ecosystem and continuous builds.
Jenkins Data
• Now your slave is up and running, let's execute a job on the slave.
• Take an existing job and run this job on this slave.
• Open the job and click on configure.
• Now here in the General section, click on “Restrict where this
project can be run”.
• Here in Label Expression, enter the name of the slave and save it.
• Now click on Build now and see the output of this job.
• Everything is correct you will see the output as Success.
Jenkins Pipelines
What is a Jenkins pipeline?
• Jenkins Pipeline (or simply "Pipeline") is a suite of plugins which
supports implementing and integrating continuous delivery
pipelines into Jenkins.
• A continuous delivery pipeline is an automated expression of your
process for getting software from version control right through to your
users and customers.
• Every change to your software (committed in source control) goes
through a complex process on its way to being released.
• This process involves building the software in a reliable and
repeatable manner, as well as progressing the built software (called a
"build") through multiple stages of testing and deployment.
• The definition of a Jenkins Pipeline is written into a text file (called
a Jenkinsfile) which in turn can be committed to a project’s source
control repository.
What is Continuous Delivery Pipeline?
• 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.
User Management in Jenkins
Step 3)
• Once the plugin is installed, a “success” status will be displayed.
• You can schedule a job for more than one time by adding more than
one entry.
• Each field can contain an exact value or use a set of special
expressions:
• The familiar asterisk * indicates all valid values. So, a job that runs
every day has a * in the third field.
• A dash separates ranges of values. For example, a job that runs
every hour from 9:00 a.m. to 5:00 p.m. would have 9-17 in the
second field.
• Intervals are specified with a slash /. A job that runs every 15
minutes has H/15 in the first field.
• Note that the H in the first field has a special meaning.
• If you wanted a job to run every 15 minutes, you could configure it
as 0/15, which would make it run at the start of every hour.
• However, if you configure too many jobs this way, you can
overload your Jenkins controller.
• Ultimately, the H tells Jenkins to pick a minute based on a hash of
the job name.
• Finally, you can specify multiple values with a comma. So, a job
that runs Monday, Wednesday, and Friday would have 1,3,5 in the
fifth field.
• Examples : # Every fifteen minutes : H/15 * * * *
# Every ten minutes in the first half of every hour : H(0-29)/10 * * * *
Builds on Slave Nodes
• The machine where we install standard Jenkins will be
our Jenkins master.
• On the slave node machine, we will install a runtime
program called Agent.
• Installing Agent will not be a standard Jenkins install, but
this Agent will run on the JVM.
• It is capable enough to run the subtask or main task of
Jenkins in a dedicated executor.
• We can have any number of Agent nodes or slave nodes.
• Further, we can configure the master node to decide
which task or job should run on which agent and how
many executor agents we can have.
• The communication between master and Jenkins slave
nodes is bi-directional and takes place over TCP/IP.
Distributed Builds
Step by step process to add Jenkins slave nodes
• In a production environment, there are lot and lot
of builds need to run in parallel.
• This is the time Jenkins slave nodes come into the play.
• We can run builds in separate Jenkins slave nodes.
• This will reduce build overhead to the Jenkins master and
we can run build in parallel.
• This step by step guide will help you to add any
flavour of Linux machine as a Jenkins slave node.
Prepare Slave nodes
• Before adding a slave node to the Jenkins master we need
to prepare the node.
• We need to install Java on the slave node.
• Jenkins will install a client program on the slave node.
• To run the client program we need to install the same Java
version we used to install on Jenkins master.
• Here we use this slave node to build Java Maven project.
• Therefore you need to install Maven as well.
• According to your production environment, you need to
install and configure the necessary tool in the slave
node.
• Install OpenJDK 8 on the slave node
# sudo yum install -y java-1.8.0-openjdk
• As mention before, now install apache maven on the slave node.
• You can find the private key with the below command
# cat /home/centos/.ssh/id_rsa
• Click on add and select the credentials we created
from the drop-down.
• Click on save.
• If you did all the correct slave node will come to live state
within a few seconds.