# DevOps Tools (Jenkins Installtion and Small demo to Access Code from Github)
###### tags: `Devops` `K8s` `Docker` `Jenkins` `Ansible` `Terraform`
## Jenkins
### CI/CD Pipelines Project:

### Jenkins Installtion Linux 20.04
#### Step 1: Installing java jdk
```javascript=
# sudo apt update
# sudo apt install default-jre
# sudo apt install default-jdk
```
#### Step 2: Installing Jenkins (Non-root user)
```javascript=
# sudo apt update
# wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
# sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
# sudo apt update
# sudo apt install jenkins
```
#### Step 3 Starting Jenkins
```javascript=
# sudo systemctl start jenkins
# sudo systemctl status jenkins
```

#### Step 4 Opening Firewall
```javascript=
# sudo apt-get install openssh-server
# sudo ufw allow OpenSSH
# sudo ufw enable
# sudo ufw allow 8080
# sudo ufw status
```

#### Step 5 Setting up Jenkins

In the terminal window, use the cat command to display the password:
```javascript=
# sudo cat /var/lib/jenkins/secrets/initialAdminPassword
```
copy the password:

paste the copied password in the administrator password box and click on continue:

Install Suggested Plugins:






#### How to connect Git Repository in Jenkins (GitHub)
Manage Jenkins -> Manage Plugins

check the installed plugin and search the git. If not installed then go to available plugin in Install git and others plugins you need.

create a new project

Enter an item name and choose the freestyle project for now and click ok.

Now you can see this page with many options. Now you can check options you need or not as per your projects needs:

Under the source management you can find the git because you add pulgin, If you cant find the git then go to manage plugins and install

Now open the browser go to github.com and signup, but I have already my account so I can use that.

login to github account.
create a new repo

Write the repo name and keep it public but its depends on you and click on creat repository.

As of now its is empty and see like this click on the create new file.

Write the name of the file and some text for demo and commit.

The File is commited and looks like this.

Now we can access this file from jenkins server. In order to do that first need to add credentials






Now you can go to add github repo in jenkins

But if you can find this error
***Failed to connect to repository : Error performing command: git ls-remote -h https://github.com/sohailanjum97/JenkinsStudy HEAD***
see this
https://hackmd.io/lma1usiPSCuieZaPUc3GdA
Now The last step is to build the job


check the lg click on any build.
