sudo su -
sudo yum update -y
java -version
sudo yum install java-1.8.0-openjdk -y or yum install java* -y
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.key
sudo yum install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Access Jenkins:
       Open your web browser and go to http://<your-instance-public-dns>:8080.
       Use the initial admin password found in:
        sudo cat /var/lib/jenkins/secrets/initialAdminPassword
To open port 8080 for your EC2 instance, you need to modify the security group associated with the
instance. Here’s how to do it:
    1. Open the Amazon EC2 Console:
            o     Sign in to your AWS Management Console.
            o     Navigate to the EC2 dashboard.
    2. Select Your Instance:
            o     In the Instances section, find and select your running instance.
    3. View Security Group:
            o     Look at the description tab for your instance to find the Security Groups listed.
             o    Click on the security group link to open the security group settings.
    4. Edit Inbound Rules:
             o    In the security group settings, go to the "Inbound rules" tab.
             o    Click on "Edit inbound rules."
    5. Add a Rule for Port 8080:
             o    Click on "Add rule."
             o    Under "Type," select "Custom TCP Rule."
             o    For "Port range," enter 8080.
             o    In the "Source" field, select "Anywhere" (0.0.0.0/0) to allow access from any IP, or
                  restrict it to a specific IP range if needed.
             o    Click on "Save rules" to apply the changes.
Error I faced :
warning: /var/cache/yum/x86_64/2/jenkins/packages/jenkins-2.479.3-1.1.noarch.rpm: Header V4
RSA/SHA512 Signature, key ID ef5975ca: NOKEY 91 MB 00:00:00 ETA Public key for jenkins-2.479.3-
1.1.noarch.rpm is not installed jenkins-2.479.3-1.1.noarch.rpm | 92 MB 00:00:07 Public key for
jenkins-2.479.3-1.1.noarch.rpm is not installed
sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-jenkins https://pkg.jenkins.io/redhat/jenkins.io.key
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-jenkins
sudo rpm -qa gpg-pubkey* --qf "%{SUMMARY}\n"
sudo yum clean all
sudo yum install jenkins
Again facing issue:
Downloading packages: warning: /var/cache/yum/x86_64/2/jenkins/packages/jenkins-2.479.3-
1.1.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID ef5975ca: NOKEY 90 MB 00:00:00 ETA
Public key for jenkins-2.479.3-1.1.noarch.rpm is not installed jenkins-2.479.3-1.1.noarch.rpm | 92
MB 00:00:08 Public key for jenkins-2.479.3-1.1.noarch.rpm is not installed
wget https://pkg.jenkins.io/redhat-stable/jenkins-2.479.3-1.1.noarch.rpm
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-jenkins https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-jenkins
sudo rpm -ivh jenkins-2.479.3-1.1.noarch.rpm
sudo systemctl start jenkins
sudo systemctl enable jenkins
Access Jenkins:
        Open your web browser and navigate to http://<your-instance-public-dns>:8080.
        Retrieve the initial admin password:
         sudo cat /var/lib/jenkins/secrets/initialAdminPassword
GitHub : webhook
 Event-driven notification system from Git-Hub that automatically trigger action in your Jenkins
server when specific events occur in your repository.
Benefits:
    1.   Reduced latency
    2.   Automatic Triggering
    3.   Traceability & visibility (New Build created)
    4.   Secured – (Listed API)
Jenkinsfile:
Git hub webhook Practical:
stage('Buid Stage') {
    steps {
        // One or more steps need to be included within the steps block.
pipeline{
        agent any
        options {
     buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr:
'30', numToKeepStr: '2')
        stages{
            stage('build stage'){
                steps{
                    echo "Hello"
Jenkins file with checkout stage
Jenkins file with the option:
Agents:
Jenkins is a Master-Slave System Based
Scalability
Maintenance
Flexibility
400 Jobs => traffic -- Distributed the traffics => By Agents
We have a machine ---(Linux Machine) --- we can attach different machine to this Linux machine like
windows machine, Mac OS machine , Docker Machine
Maintenance: There is OS increasing, upgrade available on of the server – to make sure that services
and jobs should be running. We can maintain it by Agent .