Linux 安装 jenkins

495 阅读1分钟

1、安装JDK11

安装jenkins之前需要安装JDK,本机安装的JDK11,安装JDK参考Linux 安装 JDK11 - 掘金 (juejin.cn)

2、下载安装jenkins

进入jenkins官网下载jenkins.war包,Jenkins 的安装和设置

下载最新版本:

image.png

下载之前版本:

image.png

下载好后,上传服务器,把服务存放在/usr/local/jenkins目录下

执行下列命令运行jenkis

nohup java -jar jenkins.war --httpPort=8080 &

  • --httpPort=8080 端口地址,默认8080

启动后访问 Jenkins工作台 http://服务器IP:8080/

初次进入需要输入密码,密码在/root/.jenkins/secrets/initialAdminPassword文件夹下

image.png

使用以下命令查询密码: vim /root/.jenkins/secrets/initialAdminPassword

报错信息

报错1

Fontconfig head is null, check your fonts or fonts configuration

ERROR o.a.c.c.C.[.[.[/xxx].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/xxx] threw exception [
Request processing failed; nested exception is java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration] with root cause
java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration

问题是关于字体配置的,提示Fontconfig头部为空,可能是字体文件或字体配置有问题。可以更新本地字体,在 CentOS 系统中,更新字体的命令是:sudo yum update fonts

报错2

AWT is not properly configured on this server. Perhaps you need to run your container with "-Djava.awt.headless=true"? See also: https://www.jenkins.io/redirect/troubleshooting/java.awt.headless

此报错是jdk的问题,使用下方命令配置插件

#Ubuntu9以上
apt-get install ttf-dejavu

#CentOS 6
yum install dejavu-sans-fonts

#CentOS 7
yum install fontconfig

安装后重启jenkins,启动成功。