devops

jenkins安装

虚拟机IP为192.168.36.137

我的环境为ubuntu 20.04

root@lili:/etc/netplan# lsb_release -a
LSB Version:	core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal

安装java 11(有就不需要安装了)

root@lili:/etc/netplan# java

Command 'java' not found, but can be installed with:

apt install default-jre              # version 2:1.11-72, or
apt install openjdk-11-jre-headless  # version 11.0.20.1+1-0ubuntu1~20.04
apt install openjdk-13-jre-headless  # version 13.0.7+5-0ubuntu1~20.04
apt install openjdk-16-jre-headless  # version 16.0.1+9-1~20.04
apt install openjdk-17-jre-headless  # version 17.0.8.1+1~us1-0ubuntu1~20.04
apt install openjdk-8-jre-headless   # version 8u382-ga-1~20.04.1

root@lili:/etc/netplan# apt install openjdk-11-jdk

root@lili:/etc/netplan# java -version

openjdk version "11.0.20.1" 2023-08-24

OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04)

OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode)

root@lili:/etc/netplan#

安装jenkins

jenkins 各个版本war包下载地址

下载jenkins.war

root@lili:/#mkdir /opt/jenkins 
root@lili:/#cd /opt/jenkins 
root@lili:/opt/jenkins# wget https://mirrors.jenkins.io/war-stable/2.401.3/jenkins.war

启动

root@lili:/opt/jenkins# nohup java -jar jenkins.war --httpPort=8801 > nohup.out 2>&1 &
[2] 12763

root@lili:/opt/jenkins# tail -500f nohup.out 
nohup: ignoring input
Running from: /opt/jenkins/jenkins.war
webroot: /root/.jenkins/war
2023-10-12 02:48:58.354+0000 [id=1]	INFO	winstone.Logger#logInternal: Beginning extraction from war file
2023-10-12 02:48:58.395+0000 [id=1]	WARNING	o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2023-10-12 02:48:58.422+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: jetty-10.0.13; built: 2022-12-07T20:13:20.134Z; git: 1c2636ea05c0ca8de1ffd6ca7f3a98ac084c766d; jvm 11.0.20.1+1-post-Ubuntu-0ubuntu120.04
2023-10-12 02:48:58.611+0000 [id=1]	INFO	o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2023-10-12 02:48:58.642+0000 [id=1]	INFO	o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
2023-10-12 02:48:58.928+0000 [id=1]	INFO	hudson.WebAppMain#contextInitialized: Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
2023-10-12 02:48:59.015+0000 [id=1]	INFO	o.e.j.s.handler.ContextHandler#doStart: Started w.@61e45f87{Jenkins v2.401.3,/,file:///root/.jenkins/war/,AVAILABLE}{/root/.jenkins/war}
2023-10-12 02:48:59.026+0000 [id=1]	INFO	o.e.j.server.AbstractConnector#doStart: Started ServerConnector@6a2f6f80{HTTP/1.1, (http/1.1)}{0.0.0.0:8801}
2023-10-12 02:48:59.044+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: Started Server@5ab9e72c{STARTING}[10.0.13,sto=0] @1025ms
2023-10-12 02:48:59.058+0000 [id=23]	INFO	winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2023-10-12 02:48:59.207+0000 [id=30]	INFO	jenkins.InitReactorRunner$1#onAttained: Started initialization
2023-10-12 02:48:59.211+0000 [id=31]	INFO	jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2023-10-12 02:48:59.653+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2023-10-12 02:48:59.656+0000 [id=31]	INFO	jenkins.InitReactorRunner$1#onAttained: Started all plugins
2023-10-12 02:48:59.661+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2023-10-12 02:48:59.796+0000 [id=30]	INFO	jenkins.InitReactorRunner$1#onAttained: System config loaded
2023-10-12 02:48:59.796+0000 [id=30]	INFO	jenkins.InitReactorRunner$1#onAttained: System config adapted
2023-10-12 02:48:59.796+0000 [id=30]	INFO	jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2023-10-12 02:48:59.797+0000 [id=30]	INFO	jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2023-10-12 02:48:59.858+0000 [id=44]	INFO	hudson.util.Retrier#start: Attempt #1 to do the action check updates server
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/root/.jenkins/war/WEB-INF/lib/groovy-all-2.4.21.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2023-10-12 02:49:00.130+0000 [id=30]	INFO	jenkins.install.SetupWizard#init: 

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

68f098ede13441abbdf680c3c8805ddf

This may also be found at: /root/.jenkins/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

访问Jenkins并配置

http://192.168.36.137:8801/login?from=%2F

密码在 /root/.jenkins/secrets/initialAdminPassword

选择安装推荐插件

修改Jenkins插件源为国内源,否则插件安装超级慢

备份下原配置
root@lili:/opt/jenkins#cd /root/.jenkins/updates
root@lili:/root/.jenkins/updates#cp default.json default.jsonbak
修改配置
root@lili:/root/.jenkins/updates# sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' /root/.jenkins/updates/default.json

root@lili:/root/.jenkins/updates# sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' /root/.jenkins/updates/default.json 

修改后重启下Jenkins
root@lili:~/.jenkins/updates#cd /opt/jenkins
root@lili:/opt/jenkins# ps -ef|grep jenkins
root       13109    2685  7 03:01 pts/1    00:00:21 java -jar jenkins.war --httpPort=8801
root       13203    2685  0 03:06 pts/1    00:00:00 grep --color=auto jenkins
root@lili:/opt/jenkins# kill -9 13109

root@lili:/opt/jenkins#nohup java -jar jenkins.war --httpPort=8801 > nohup.out 2>&1 &

留言

您的邮箱地址不会被公开。 必填项已用 * 标注

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。
转载请注明来源:jenkins安装 - 多知在线