web-dev-qa-db-fra.com

Échec de l'installation de Jenkins dans Ubuntu 18.04 LTS (Échec du démarrage de LSB: démarrez Jenkins au démarrage.)

[Symptômes]

  • Installez Jenkins en utilisant les étapes officielles, mais a échoué avec le message d'erreur Impossible de démarrer LSB: démarrez Jenkins au démarrage.
  • Reproduire les étapes

    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | Sudo apt-key add -
    Sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/"
    Sudo apt install jenkins
    
  • Journal de la console

    gaspar@jenkins:~$ Sudo apt install jenkins
    ...
    Setting up default-jre-headless (2:1.9-62ubuntu2) ...
    Setting up jenkins (2.107.2) ...
    Job for jenkins.service failed because the control process exited with error code.
    See "systemctl status jenkins.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript jenkins, action "start" failed.
    ● jenkins.service - LSB: Start Jenkins at boot time
       Loaded: loaded (/etc/init.d/jenkins; generated)
       Active: failed (Result: exit-code) since Thu 2018-04-19 10:03:05 UTC; 9ms ago
         Docs: man:systemd-sysv-generator(8)
      Process: 27282 ExecStart=/etc/init.d/jenkins start (code=exited, status=7)
    Apr 19 10:03:03 evt-jenkins systemd[1]: Starting LSB: Start Jenkins at boot time...
    Apr 19 10:03:03 evt-jenkins jenkins[27282]:  * Starting Jenkins Automation Server jenkins
    Apr 19 10:03:03 evt-jenkins su[27313]: Successful su for jenkins by root
    Apr 19 10:03:03 evt-jenkins su[27313]: + ??? root:jenkins
    Apr 19 10:03:03 evt-jenkins su[27313]: pam_unix(su:session): session opened for user jenkins by (uid=0)
    Apr 19 10:03:03 evt-jenkins su[27313]: pam_unix(su:session): session closed for user jenkins
    Apr 19 10:03:05 evt-jenkins jenkins[27282]:    ...fail!
    Apr 19 10:03:05 evt-jenkins systemd[1]: jenkins.service: Control process exited, code=exited status=7
    Apr 19 10:03:05 evt-jenkins systemd[1]: jenkins.service: Failed with result 'exit-code'.
    Apr 19 10:03:05 evt-jenkins systemd[1]: Failed to start LSB: Start Jenkins at boot time.
    dpkg: error processing package jenkins (--configure):
     installed jenkins package post-installation script subprocess returned error exit status 1
    ...
    

[Environnement]

  • Ubuntu 18.04 LTS Beta2
  • Jenkins 2.107.2
16
Gaspar Cheng

[Cause première]

  • Ubuntu 18.04 LTS utilise Java 9 par défaut, Java
  • Jenkins 2.107.2 utilise toujours Java 8

[Solution]

  • Installer Java 8 avant d'installer Jenkins

    Sudo add-apt-repository ppa:webupd8team/Java
    Sudo apt install Oracle-Java8-installer
    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | Sudo apt-key add -
    Sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/"
    Sudo apt-get update
    Sudo apt install jenkins
    
36
Gaspar Cheng
  1. Installer Java 8
Sudo apt install openjdk-8-jre
  1. Définir la valeur par défaut Java version = Java 8
Sudo update-alternatives --config Java
  1. Ajouter la clé
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | Sudo apt-key add -
  1. Ajouter un référentiel
Sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/"
  1. Installer des Jenkins
Sudo apt install jenkins
12