Ubuntu1804/Ubun2004安装jenkins
上传jdk软件包
root@ubuntu-1:~# ls jdk-8u191-linux-x64.tar.gz
解压jdk,并配置环境变量
解压jdk root@ubuntu-1:~# tar xf jdk-8u191-linux-x64.tar.gz -C /usr/local/ 创建软连接,方便系统调用 root@ubuntu-1:~# ln -s /usr/local/jdk1.8.0_191/ /usr/local/jdk 配置jdk环境变量 cat > /etc/profile.d/jdk.sh <<EOF export JAVA_HOME=/usr/local/jdk export JRE_HOME=\$JAVA_HOME/jre export CLASSPATH=\$JAVA_HOME/lib/:\$JRE_HOME/lib/ export PATH=\$PATH:\$JAVA_HOME/bin EOF 让环境变量生效 root@ubuntu-1:~# source /etc/profile.d/jdk.sh 创建软连接,如果不创建,安装的时候可能会报错 root@ubuntu-1:~# ln -s /usr/local/jdk/bin/java /bin/java 查看环境变量是否生效 root@ubuntu-1:~# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
安装jenkins
下载jenkins root@ubuntu-1:~# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/debian-stable/jenkins_2.346.2_all.deb 安装jenkins(需要用root用户安装jenkins,普通用户安装权限不足) root@ubuntu-1:~# dpkg -i jenkins_2.346.2_all.deb 查看jenkins状态 root@ubuntu-1:~# systemctl status jenkins.service ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2022-07-21 07:15:16 UTC; 2min 49s ago Main PID: 118900 (java) Tasks: 38 (limit: 4582) Memory: 493.4M CGroup: /system.slice/jenkins.service └─118900 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 Jul 21 07:14:59 ubuntu-1 jenkins[118900]: Jenkins initial setup is required. An admin user has been created and a password generated. Jul 21 07:14:59 ubuntu-1 jenkins[118900]: Please use the following password to proceed to installation: Jul 21 07:14:59 ubuntu-1 jenkins[118900]: 22ab5e5b61f542fbb3514845f617d45b Jul 21 07:14:59 ubuntu-1 jenkins[118900]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword Jul 21 07:14:59 ubuntu-1 jenkins[118900]: ************************************************************* Jul 21 07:14:59 ubuntu-1 jenkins[118900]: ************************************************************* Jul 21 07:14:59 ubuntu-1 jenkins[118900]: ************************************************************* Jul 21 07:15:16 ubuntu-1 jenkins[118900]: 2022-07-21 07:15:16.284+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization Jul 21 07:15:16 ubuntu-1 jenkins[118900]: 2022-07-21 07:15:16.294+0000 [id=21] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running Jul 21 07:15:16 ubuntu-1 systemd[1]: Started Jenkins Continuous Integration Server.
通过web界面访问jenkins,密码在/var/lib/jenkins/secrets/initialAdminPassword
http://10.0.0.40:8080/
查看密码
root@ubuntu-1:~# cat /var/lib/jenkins/secrets/initialAdminPassword 22ab5e5b61f542fbb3514845f617d45b
1
修改密码