Error with Jenkins installation on Ubuntu 20.04

Viewed 1539

I'm trying to install Jenkins on an Azure VM with Ubuntu 20.04 following the next command lines:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
    /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update -y
sudo apt-get install jenkins -y

But when I try to install Jenkins with the last command, this happens:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  jenkins
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 91.4 MB of archives.
After this operation, 95.0 MB of additional disk space will be used.
Err:1 https://pkg.jenkins.io/debian-stable binary/ jenkins 2.332.3
  Redirection from https to 'http://mirrors.jenkins.io/debian-stable/jenkins_2.332.3_all.deb' is forbidden [IP: 146.75.30.133 443]
E: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/jenkins_2.332.3_all.deb  Redirection from https to 'http://mirrors.jenkins.io/debian-stable/jenkins_2.332.3_all.deb' is forbidden [IP: 146.75.30.133 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

How can I solve this issue?

5 Answers

I actually solved the problem, I don't know why with the actuall Jenkins installation guide it doesn't work but i solved it with these 2 command lines:

wget https://pkg.jenkins.io/debian-stable/binary/jenkins_2.332.3_all.deb
sudo dpkg -i jenkins_2.332.3_all.deb

I've been trying with some versions till I found the one that worked, and now Jenkins is working.

https://deb.pkgs.org/packages/jenkins/jenkins_2.332.3_all.deb.html

(Ubuntu 22.04) I have installed "net-tools" manually and just after that "Jenkins" has started to install. Accordingly, I've changed my Ansible yaml

---
- name: Install dependencies
  apt:
    name: net-tools
    state: present

- name: ensure the jenkins apt repository key is installed
  apt_key:
<skipped>

it was solved for me,

  1. i'm running ubuntu 20.04 in AWS EC2 NEW instance

  2. first command that im used in it

    sudo su - (to enter the root user)

  3. Update the repository

    apt update

  4. Install net-tools

    apt install net-tools

  5. Install JAVA, 'cause the jenkins can be running with JAVA

    apt -y install openjdk-11-jdk

  6. Edit the Java's path

    find /usr/lib/jvm/java-1.11* (copy the output of that command)

  7. Add JAVA PATH

    nano /etc/environment (Open the file) JAVA_HOME="/usr/lib/jvm/java-1.11.0-openjdk-amd64" (add this command) CTRL + X and Y and ENTER (for save that file)

  8. Reload the file

    source /etc/environment

  9. And check the PATH

    echo $JAVA_HOME (the output will be pretty same like step number 6)

  10. Those were the requirement before you install the Jenkins

  11. Download the jenkins file

    wget https://pkg.jenkins.io/debian-stable/binary/jenkins_2.332.3_all.deb

  12. And then install it

    dpkg -i jenkins_2.332.3_all.deb

  13. The installation will be success, now you can see your jenkins in EC2

    [your-ip-public]:8080 ('cause the jenkins is run with 8080 port, we need add new rule of securtiy group in our EC2 instance)

I hope this helps

Before installing Jenkins, you need to do,

sudo apt-get upgrade

sudo apt-get update

Then install,

sudo apt-get install jenkins -y

You can install Jenkins with docker via docker-compose.

  version: "3.1"
  services:
    jenkins:
      image: jenkins:latest
      ports:
        - 8080:8080
        - 50000:50000
      volumes:
        - jenkins-home:/var/jenkins_home
  
  volumes:
    jenkins-home:

Before installation -> sudo apt install docker.io docker-compose -y

Related