Jenkins Failed to Start in Linux

Jenkins failed to start in linux

So, knowing it was a pre-start error allowed me to investigate more deeply.

Further digging allowed me to figure out that the exact line in the /etc/init/jenkins.conf file was one pointing to the /usr/share/jenkins/bin/maintain-plugins.sh

Looking at this location, I found it was not present (ie. no bin directory). This means that jenkins-common was no longer installed for some reason...odd indeed...going into apt-get and doing an install of this component again led to the error:

dpkg error processing /var/cache/apt/archives/jenkins-common_1.409.1-0ubuntu4.2_all.deb ...

having seen this error before and refreshing my memory via google gave the following solution:

dpkg -i --force-overwrite /var/cache/apt/archives/jenkins-common_1.409.1-0ubuntu4.2_all.deb

This allowed the installation of common to proceed as normal. After this, all I had to do was replace the /usr/share/jenkins/jenkins.war with my backed up copy (because ubuntu is far behind the latest release version), and I was able to start the server again.

I am not exactly sure what caused the problem to begin with, but it was likely during an apt-get upgrade/clean process...and because of the weirdness with jenkins conflicting with jenkins-common, it did not repopulate the /usr/share/jenkins directory properly.

regardless, am glad it is working again. :)

Jenkins fails when running service start jenkins

Similar problem on Ubuntu 16.04.

Setting up jenkins (2.72) ...
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; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-08-01 05:39:06 UTC; 7ms ago
Docs: man:systemd-sysv-generator(8)
Process: 3700 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)

Aug 01 05:39:06 ip-0 systemd[1]: Starting LSB: Start Jenkins ....
Aug 01 05:39:06 ip-0 jenkins[3700]: ERROR: No Java executable ...
Aug 01 05:39:06 ip-0 jenkins[3700]: If you actually have java ...
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Control pro...1
Aug 01 05:39:06 ip-0 systemd[1]: Failed to start LSB: Start J....
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Unit entere....
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Failed with....

To fix the issue manually install Java Runtime Environment:

JDK version 9:

sudo apt install openjdk-9-jre

JDK version 8:

sudo apt install openjdk-8-jre

Open Jenkins configuration file:

sudo vi /etc/init.d/jenkins

Finally, append path to the new java executable (line 16):

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/jvm/java-8-openjdk-amd64/bin/

Jenkins failed to start - Verify that you have sufficient privileges to start system services

Important: If you retried the installation too many times, skip down to "Option 2". The local user account that runs Jenkins may be locked. You will need to unlock that account before attempting either fix below.


This is how I fixed the problem.

Option 1: Re-enter credentials for jenkins user

Please read it all before executing and follow the steps in order:

  1. Delete any Jenkins installation leftovers you currently have
  2. Start the installation process, input your credentials when asked, and continue with the on-screen instructions (including choosing the JDK folder) up until the point where the error is raised.
  3. When the error is raised, >>> DO NOT DO ANYTHING! <<< leave it as it is shown in my question
  4. Now (and only now), open "Services"
  5. Search for the "Jenkins" service. It should be set to "Automatic", but it might be "Disabled"
    Sample Image
  6. Open the "Jenkins" properties, and go to the "Log On" tab
    Sample Image
  7. Make sure you choose the "This account" radio button, delete the account name and password fields, and enter them AGAIN
  8. Click "Apply"
  9. Go back to the installer and click "Retry"

If everything is according to plan - The installation will now continue without a problem.

This method was tested on a local and VM / AWS computer and worked!

If you still encounter a problem, try changing the startup in step 5 to "Automatic" and make sure you only open "Services" on step 4. "Services" will not update while it is open.

Option 2: Unlock jenkins user account and manually start service

If you encounter the "Service 'Jenkins' failed to start" error too many times, the account on your computer that should run Jenkins will become locked. You will need to unlock that local account first. Keep the Jenkins installation window open with the error message, and then perform the following steps:

  1. Open the "Local Users and Groups" application.
  2. Go into the "Users" folder.
  3. Right-click on the user who will run the Jenkins service, and click "Properties".
  4. Uncheck "Account is locked out". And while you are at it, make sure "Account is disabled" is unchecked as well.
  5. Click OK.
  6. Open the "Services" app on your computer.
  7. Make sure the Jenkins service is set to start automatically.
  8. Right-click the Jenkins service and click "Start". The service should start successfully.
  9. Switch back to the Jenkins installation window with the "insufficient privileges" message still showing.
  10. Click the "Retry" button in the "insufficient privileges" message box. The installer should recognize that the Jenkins service has started.

You should be able to finish the installation.

jenkins fails to start correctly, despite lack of error output

The answer was fairly straightforward, and dare I say obvious: I needed to reinstall jenkins. I'm on RHEL, but this could be adapted for ubuntu, etc. (see link below).

# stop the jenkins service altogether
sudo service jenkins stop

# backup jenkins_home files
sudo cp -r /var/lib/jenkins ~/.jenkins_home_backup

# remove the jenkins installation entirely
sudo yum remove jenkins # remove existing jenkins install

# add the jenkins ssh key locally
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

# reinstall jenkins
sudo yum -y install jenkins

# start jenkins!
sudo service jenkins start

More or less adapted from: https://computingforgeeks.com/how-to-install-jenkins-on-centos-rhel-8/

You may need to also reference: https://www.jenkins.io/blog/2020/07/27/repository-signing-keys-changing/

Jenkins fails to start on centOS7

Before you can install Jenkins, you need to setup a Java virtual machine on your system

yum install java-1.8.0-openjdk.x86_64

And set two environment variables: JAVA_HOME and JRE_HOME.

echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
source /etc/profile

Then install jenkins and allow inbound traffic on port 8080.

You can see more details from how to install jenkins on Centos 7.

Hope this helps.



Related Topics



Leave a reply



Submit