# Creating Jenkins Server

Now creating the Jenkins server

<figure><img src="/files/53hquBsXsoZwyKHb4gsr" alt=""><figcaption></figcaption></figure>

t2.small

same security group

ssh into it then start running the following commands

First updating the packages

```sh
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 
```

<figure><img src="/files/AfqyLMqdVuZnOKnbnGiG" alt=""><figcaption></figcaption></figure>

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:

```sh
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

```sh
sudo systemctl restart jenkins
```

<figure><img src="/files/yBo23YvMBWfINexLxoeV" alt=""><figcaption></figcaption></figure>

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`

<figure><img src="/files/CVCmf48ovqhM3uS1Vlsf" alt=""><figcaption></figcaption></figure>

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

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

Enter the password and select Install suggested plugins.

<figure><img src="/files/uhmWFF5EmGTlEFPhJDxx" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://oklencodes.gitbook.io/untitled/devops/using-aws-docker-jenkins-and-sonarqube-to-improve-code-quality/creating-jenkins-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
