Ubuntu 16.04下Jenkins 2.107.2服务启动失败求助
Hey there, let's work through this Jenkins startup issue together. First, let's recap what we know about your setup:
- You installed Jenkins 2.107.2 via
sudo apt-get install jenkins - Your JDK is Oracle Java 8 Update 40 (
java version "1.8.0_40") - The startup error you're seeing is:
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
Since you ran systemctl status jenkins.service but haven't shared the full output yet, let's go through the most common fixes and diagnostic steps first:
1. Get Detailed Logs for Precise Debugging
First, pull the full, untruncated status logs to see exactly what's failing — truncated logs often hide critical details:
systemctl status jenkins.service -l
Also, check the recent Jenkins-specific journal logs for more context:
journalctl -u jenkins.service --since "10 minutes ago"
Look for keywords like ERROR, Failed, or Permission denied — these will point us directly to the root cause.
2. Ensure Jenkins is Using the Correct JDK
Jenkins relies on a full JDK (not just a JRE) and often needs explicit configuration to use your Oracle JDK instead of a default OpenJDK installation. Here's how to fix this:
- Open the Jenkins default config file:
sudo nano /etc/default/jenkins - Look for the
JAVA_HOMEline — it might be commented out or pointing to the wrong path. - First, confirm your Oracle JDK 8 installation path with:
This will output something likeupdate-alternatives --list java/usr/lib/jvm/java-8-oracle/jre/bin/java— use the parent directory (e.g.,/usr/lib/jvm/java-8-oracle) as yourJAVA_HOMEvalue. - Update the
JAVA_HOMEline to match, save the file (Ctrl+O, Enter, then Ctrl+X), then restart Jenkins:sudo systemctl restart jenkins
3. Check for Port Conflicts
Jenkins uses port 8080 by default. If another service (like Tomcat, another Jenkins instance, or a web server) is using this port, Jenkins will fail to start. Verify with:
sudo lsof -i :8080 # Or alternatively: sudo netstat -tulpn | grep 8080
If you see a process using port 8080, you can either stop that process or change Jenkins' port in /etc/default/jenkins by modifying the HTTP_PORT line (e.g., change it to 8081), then restart the service.
4. Fix File Permission Issues
The Jenkins user needs full ownership of its working and log directories to function properly. Check the permissions:
ls -ld /var/lib/jenkins ls -ld /var/log/jenkins
Both directories should show ownership as jenkins:jenkins. If not, fix the permissions with:
sudo chown -R jenkins:jenkins /var/lib/jenkins sudo chown -R jenkins:jenkins /var/log/jenkins
Then restart Jenkins again.
5. Verify JDK Functionality
Even though your java -version looks good, ensure the full JDK (not just JRE) is installed and working. Run:
javac -version
If this throws an error, you only have the JRE installed — Jenkins requires the full JDK. Install it with:
sudo apt-get install oracle-java8-jdk
(Note: You might need to add the Oracle JDK repository first if it's not already configured on your system.)
If after trying these steps Jenkins still won't start, share the full output from systemctl status jenkins.service -l and we can dig deeper into the specific failure!
内容的提问来源于stack exchange,提问作者Haiping

