0% found this document useful (0 votes)
18 views

Jenkins Notes

Uploaded by

jixoooh4jn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Jenkins Notes

Uploaded by

jixoooh4jn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Jenkins is way to build, test and deploy your code.

CI/CD refers to the Continuous Integration and Continuous Delivery/Deployment process. It’s a
process of taking the code, packaging it and deploying it to a System(EC2, VM, Container,
Serverless). During Continuous Integration process we do unit tests, integration tests, and
security checks on the code, check the dependencies,
Jenkins is an Automation Server. We can use Jenkins to automate routine system administration
tasks.
We can host Jenkins on a VM, local system, containers, EC2. Java is a prerequisite for Jenkins
installation.

Installing Jenkins on CentOS VM


sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-
stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install fontconfig java-17-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload

sudo systemctl enable jenkins #you can enable jenkins to start at the boot

sudo systemctl start jenkins #starts the jenkins service

sudo systemctl status jenkins #to check the status of the jenkins service

If you have a firewall installed, you must add Jenkins as an exception. You must change
YOURPORT in the script below to the port you want to use. Port 8080 is the most common.

YOURPORT=8080
PERM="--permanent"
SERV="$PERM --service=jenkins"

firewall-cmd $PERM --new-service=jenkins


firewall-cmd $SERV --set-short="Jenkins ports"
firewall-cmd $SERV --set-description="Jenkins port exceptions"
firewall-cmd $SERV --add-port=$YOURPORT/tcp
firewall-cmd $PERM --add-service=jenkins
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

When you first access a new Jenkins instance, you are asked to unlock it using an automatically-
generated password.

(1). Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing
it) and wait until the Unlock Jenkins page appears.
(2). The command: sudo cat /var/lib/jenkins/secrets/initialAdminPassword will print the password
at console.
(3). If you are running Jenkins in Docker using the official jenkins/jenkins image you can use sudo
docker exec ${CONTAINER_ID or CONTAINER_NAME} cat
/var/jenkins_home/secrets/initialAdminPassword to print the password in the console without
having to exec into the container.

After unlocking Jenkins, the Customize Jenkins page appears. Here you can install any number of
useful plugins as part of your initial setup.

Click one of the two options shown:

Install suggested plugins - to install the recommended set of plugins, which are based on
most common use cases.
Select plugins to install - to choose which set of plugins to initially install. When you first
access the plugin selection page, the suggested plugins are selected by default.

Finally, after customizing Jenkins with plugins, Jenkins asks you to create your first administrator
user.
When the Create First Admin User page appears, specify the details for your administrator user
in the respective fields and click Save and Finish.
When the Jenkins is ready page appears, click Start using Jenkins.

We can use Jenkins CLI if you are comfortable with the CLI.

The public key has a .pub extension and is called jenkins_key.pub


Now add this public key (/home/mike/.ssh/jenkins_key.pub) in Jenkins for the user called mike
under configure section of the user.This will allow us to interact with Jenkins using the CLI.
We have configured the SSH service in Jenkins to listen on a fixed port. To find out the port in
use, run the command below:
curl -Lv http://localhost:8085/login 2>&1 | grep -i 'x-ssh-endpoint'

let us begin interacting with Jenkins over ssh with the user mike:
mike@jenkins-server:~$ ssh -i /home/mike/.ssh/jenkins_key -l mike -p 8022 jenkins-server help

Keep a note of the options used with the SSH command:


-i flag is used to point to mike's private SSH key. Remember, we have already added the public
key in the Jenkins configuration.
-l is the login user which in our example is mike
-p is the port which we found out in the previous step to be 8022

You might also like