Creating Jenkins Server

Now creating the Jenkins server

t2.small

same security group

ssh into it then start running the following commands

First updating the packages

sudo apt update -y 

sudo apt install openjdk-11-jre -y 

Now installing Jenkins

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

sudo apt-get update -y 

sudo apt-get install jenkins -y

sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins 

After Jenkins finishes installing we need to change the port since its default is 8080 and Tomcat is going to need that port.

You can change the port here:

sudo nano /etc/default/jenkins

scroll down to HTTP_PORT=8080 and change it to 8082

After changing the port do not forget to restart jenkins

sudo systemctl restart jenkins

Now we can grab the public IP of the instance with the port 8082 and verify that Jenkins works.

If for some reason Jenkins is still working on port 8080 after you change it, do the following:

open the file /usr/lib/systemd/system/jenkins.service

search for the content "Environment="JENKINS_PORT=8080". Change the port number to your desired sudo systemctl daemon-reload sudo systemctl restart jenkins.service

The password was provided initially but if you did not save it then, you can type

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Enter the password and select Install suggested plugins.

Last updated