首页 > 系统相关 >Ubuntu升级Jenkins导致无法启动,报错Failed to start Jenkins Continuous Integration Server. 的一种解决方法

Ubuntu升级Jenkins导致无法启动,报错Failed to start Jenkins Continuous Integration Server. 的一种解决方法

时间:2024-07-31 14:28:41浏览次数:15  
标签:systemd java service Continuous 报错 jenkins Jenkins root

背景:从23年底部署jenkins后就没升过级,安装插件顺手更新后导致无法启动,服务端运行状态显示 jenkins systemd[1]: Failed to start Jenkins Continuous Integration Server.

无法重新启动的状态信息

root@jenkins:~# sudo systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/jenkins.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Tue 2024-07-30 17:16:14 CST; 24s ago
    Process: 5405 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
   Main PID: 5405 (code=exited, status=1/FAILURE)

Jul 30 17:16:14 jenkins systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 5.
Jul 30 17:16:14 jenkins systemd[1]: Stopped Jenkins Continuous Integration Server.
Jul 30 17:16:14 jenkins systemd[1]: jenkins.service: Start request repeated too quickly.
Jul 30 17:16:14 jenkins systemd[1]: jenkins.service: Failed with result 'exit-code'.
Jul 30 17:16:14 jenkins systemd[1]: Failed to start Jenkins Continuous Integration Server.

重点关注:jenkins systemd[1]: jenkins.service: Failed with result 'exit-code'.

起初以为是更新了版本后,jdk版本不匹配,于是先升级jdk到11 (2.346之后貌似最低要求11)

sudo apt update
sudo apt install openjdk-11-jdk

查看java 和 jenkins 版本的命令

java --version
jenkins --version

顺便列举 ubuntu 切换多个jdk的命令,进入后按数字选择即可

update-alternatives --config java

至此,理论上jenkins的版本和java版本应该是互相匹配了,那么修改jenkins的配置,指定java路径

# 查看java目录
root@jenkins:~# which java
/usr/bin/java

# jenkins配置目录
vim /lib/systemd/system/jenkins.service

# 配置到jenkins的语句
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"

# jenkins的这两个配置也可以改为root,避免有权限问题
User=root
Group=root

# jenkins服务的端口号 8080
Environment="JENKINS_PORT=8080"

生效配置,并尝试启动jenkins

systemctl daemon-reload
systemctl start jenkins.service
systemctl status jenkins.service

若仍然失败,则继续查询jenkins的详细报错日志

sudo journalctl -u jenkins.service

我这边仍然无法启动的报错信息:

Starting Jenkins Continuous Integration Server...
Running from: /usr/share/java/jenkins.war
Exception in thread "main" java.io.UncheckedIOException: java.nio.file.NoSuchFileException: /var/log/root/root.log
        at executable.Main.main(Main.java:357)
Caused by: java.nio.file.NoSuchFileException: /var/log/root/root.log
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:220)
        at winstone.Launcher.initLogger(Launcher.java:581)
        at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:83)
        at winstone.Launcher.getArgsFromCommandLine(Launcher.java:506)
        at winstone.Launcher.main(Launcher.java:468)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at executable.Main.main(Main.java:351)
jenkins.service: Main process exited, code=exited, status=1/FAILURE
jenkins.service: Failed with result 'exit-code'.
Failed to start Jenkins Continuous Integration Server.
jenkins.service: Scheduled restart job, restart counter is at 5.
Stopped Jenkins Continuous Integration Server.
jenkins.service: Start request repeated too quickly.
jenkins.service: Failed with result 'exit-code'.
Failed to start Jenkins Continuous Integration Server.

重点关注:Caused by: java.nio.file.NoSuchFileException: /var/log/root/root.log

其实就是没有目录 /var/log/root 或者没有找到文件 root.log,不管是因为权限还是真的不存在

按这个目录创建对应需要的文件夹和日志文件后,自然可以成功启动

或者在另一份配置文件中调整日志输出的路径,也可以达到一样的效果

vi /etc/default/jenkins

JENKINS_LOG=/var/log/$NAME/$NAME.log

标签:systemd,java,service,Continuous,报错,jenkins,Jenkins,root
From: https://blog.csdn.net/qq_43728899/article/details/140814479

相关文章

  • pip安装mysqlclient报错
    pip安装mysqlclient报错报错信息Exception:Cannotfindvalidpkg-configname.SpecifyMYSQLCLIENT_CFLAGSandMYSQLCLIENT_LDFLAGSenvvarsmanually这个问题通常是由于缺少mysqlclient的开发包或者相关的环境变量导致的。要解决这个问题,你可以尝试以下几个步骤......
  • 【YashanDB知识库】ycm纳管主机安装YCM-AGENT时报错“任务提交失败,无法连接主机”
    问题现象执行安装ycm-agent命令纳管主机时报错问题的风险及影响会导致ycm-agent纳管不成功,YCM无法监控主机和数据库问题影响的版本yashandb-cloud-manager-23.2.1.100-linux-aarch64.tar问题发生原因因为10.149.223.121对ycm的主机没有开放端口9070或9071解决方法及规避......
  • python导入包报错ImportError: cannot import name ‘Protocol‘
    python32.pyTraceback(mostrecentcalllast):File"2.py",line5,in<module>importptwt#use"fromsrcimportptwt"foraclonedtherepoFile"……lib/python3.6/site-packages/ptwt/_util.py",line2......
  • 解决报错“AttributeError: ‘Collection‘ object has no attribute ‘model_fields
    在运行python文件时代码报错:这个错误是由于我们尝试访问一个对象的属性或方法,但该对象并不具备该属性或方法。在这种情况下,我们需要检查你的代码,确保正在访问的对象确实具有尝试访问的属性或方法。但是根据经验!这种(havenoattribute的报错问题)经常是因为版本问题,版本更新以......
  • Jenkins环境变量与构建工具 (pipeline)
     Jenkins内置变量pipeline{agentanystages{stage('mcwtest'){steps{echo"Running${env.BUILD_NUMBER}on${env.JENKINS_URL}"//方法一echo"Running$env.BUILD_NUMBERo......
  • python高性能计算:cython使用openmp并行 —— 报错:undefined symbol: omp_get_thread_n
    test.pyx文件:fromcython.parallelcimportparallelfromopenmpcimportomp_get_thread_numcpdefvoidlong_running_task1()noexceptnogil:whileTrue:passcpdefvoidlong_running_task2()noexceptnogil:whileTrue:passdefdo......
  • unity报错CommandWithNoStdoutInvokationFailure: Unable to start ADB server.
    这个错误提示表明Unity无法启动ADB(AndroidDebugBridge)服务器,这通常是因为AndroidSDK没有安装或者配置不正确。以下是一些解决这个问题的步骤:确认AndroidSDK的安装:确保你已经安装了AndroidSDK。可以通过AndroidStudio来安装SDK,或者从Android开发者网站下载。配置U......
  • jenkins
    jenkins简介Jenkins是一款开源CI&CD软件,用于自动化各种任务,包括构建、测试和部署软件。Jenkins支持各种运行方式,可通过系统包、Docker或者通过一个独立的Java程序。maven下载地址:https://maven.apache.org/download.cgijdk安装jdk下载地址:https://download.or......
  • linux+jenkins+github+.net core CI/CD 快速部署
    目标:代码提交后,在jenkins点击build,编译通过后能让linux更新.netcore文件和重新运行 步骤:1.腾讯云搞一台免费linux服务器:https://cloud.tencent.com/2.服务上安装jenkinshttps://www.jenkins.io/doc/book/installing/linux/#red-hat-centos3.腾讯云防火墙开放8080端口,另一......
  • 踩坑日记2:idea上git提交出现443报错
    idea代码push踩坑不改代理配置会出现Git报错:Failedtoconnecttogithub.comport443解决方案:https://blog.csdn.net/zpf1813763637/article/details/1283401091.找到代理的端口号在电脑上搜索代理服务器即可2.输入以下指令gitconfig--global--replace-allhttp.prox......