Jenkins 安装
Jenkins官网地址:https://www.jenkins.io/zh/download/
JDK下载地址:https://www.oracle.com/java/technologies/downloads/
清华源下载RPM包地址:https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/
一、安装JDK
[root@jenkins ~]# ls
install.sh
jdk-8u361-linux-x64.tar.gz
jenkins-2.416-1.1.noarch.rpm
original-ks.cfg
[root@jenkins ~]# tar -xf jdk-8u361-linux-x64.tar.gz
[root@jenkins ~]# ls
install.sh
jdk1.8.0_361
jdk-8u361-linux-x64.tar.gz
jenkins-2.416-1.1.noarch.rpm
original-ks.cfg
[root@jenkins ~]# mv jdk1.8.0_361/ /usr/local/
[root@jenkins ~]# ln -s /usr/local/jdk1.8.0_361/ /usr/local/java
[root@jenkins ~]# ll /usr/local/
total 6344
drwxr-xr-x. 2 root root 150 Jan 29 2023 bin
drwxr-xr-x 2 root root 6 Jan 29 2023 btjdk
drwxr-xr-x 2 root root 6 Jan 29 2023 bttomcat
drwxr-xr-x 6 root root 56 Jan 29 2023 curl
drwxr-xr-x. 2 root root 6 Jun 22 2021 etc
drwxr-xr-x. 2 root root 6 Jun 22 2021 games
drwxr-xr-x. 5 root root 99 Jan 29 2023 include
lrwxrwxrwx 1 root root 24 Aug 5 01:27 java -> /usr/local/jdk1.8.0_361/
drwxr-xr-x 8 root root 4096 Aug 5 01:26 jdk1.8.0_361
drwxr-xr-x. 4 root root 4096 Jan 29 2023 lib
drwxr-xr-x. 3 root root 43 Jan 29 2023 lib64
drwxr-xr-x. 2 root root 6 Jun 22 2021 libexec
drwxr-xr-x 6 root root 56 Jan 29 2023 libiconv
drwxr-xr-x 3 root root 18 Jan 29 2023 man
drwxr-xr-x 3 root root 18 Jan 29 2023 nginx
drwxr-xr-x 9 root root 113 Jan 29 2023 openssl
drwxr-xr-x. 2 root root 6 Jun 22 2021 sbin
drwxr-xr-x. 10 root root 120 Jan 29 2023 share
drwxr-xr-x. 2 root root 6 Jun 22 2021 src
-rwxr-xr-x 1 root root 6486345 Aug 10 2022 vm-agent
[root@jenkins ~]# vim /etc/profile
....
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
[root@jenkins ~]# source /etc/profile
[root@jenkins ~]# env |grep JAVA
JAVA_HOME=/usr/local/java
[root@jenkins ~]# java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
二、安装jenkins
[root@jenkins ~]# ls
install.sh jenkins-2.416-1.1.noarch.rpm
jdk-8u361-linux-x64.tar.gz original-ks.cfg
[root@jenkins ~]# rpm -ivh jenkins-2.416-1.1.noarch.rpm
warning: jenkins-2.416-1.1.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID ef5975ca: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:jenkins-2.416-1.1 ################################# [100%]
[root@jenkins ~]# systemctl daemon-reload
这里的报错,只需要安装跟jenkins匹配的版本即可
[root@jenkins ~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
[root@jenkins ~]# yum install fontconfig java-11-openjdk -y
[root@jenkins ~]# java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
[root@jenkins ~]# systemctl start jenkins
[root@jenkins ~]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2023-08-05 01:34:44 CST; 11s ago
Main PID: 4179 (java)
Tasks: 42 (limit: 10931)
Memory: 436.1M
CGroup: /system.slice/jenkins.service
└─4179 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
Aug 05 01:34:10 jenkins jenkins[4179]: Jenkins initial setup is required. An admin user has been created and a password generated.
Aug 05 01:34:10 jenkins jenkins[4179]: Please use the following password to proceed to installation:
Aug 05 01:34:10 jenkins jenkins[4179]: 8aa6ae338cbb42b8b8385a33c4048267
Aug 05 01:34:10 jenkins jenkins[4179]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Aug 05 01:34:10 jenkins jenkins[4179]: *************************************************************
Aug 05 01:34:44 jenkins jenkins[4179]: 2023-08-04 17:34:44.786+0000 [id=28] INFO jenkins.InitReactorRunner$1#onAttained: Complet>
Aug 05 01:34:44 jenkins jenkins[4179]: 2023-08-04 17:34:44.809+0000 [id=22] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is >
Aug 05 01:34:44 jenkins systemd[1]: Started Jenkins Continuous Integration Server.
Aug 05 01:34:45 jenkins jenkins[4179]: 2023-08-04 17:34:45.134+0000 [id=46] INFO h.m.DownloadService$Downloadable#load: Obtained>
Aug 05 01:34:45 jenkins jenkins[4179]: 2023-08-04 17:34:45.134+0000 [id=46] INFO hudson.util.Retrier#start: Performed the action>
jenkins配置文件
[root@jenkinso1 learn_jenkins]# rpm -ql jenkins/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins/
usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
jenkins加载插件很多,非常吃内存,且所有操作都是io操作,需要系统1o速度较快,需要机器配置较高jenkins配置文件:
jenkins配置文件: /etc/sysconfig/jenkins
jenkins核心目录: /var/lib/jenkins
/usr/lib/jenkins/jenkins.war WAR包
/etc/sysconfig/jenkins 配置文件
/var/lib/jenkins/ 默认的JENKINS_HOME目录
/var/log/Jenkins/Jenkins.log Jenkins日志文件
/var/lib/jenkins/secrets/initialAdminPassword 存放初始密码
/var/lib/jenkins/plugins插件目录
jenkins 是由xml文件组成的,也是针对某个用户生成的
用户配置信息
[root@jenkins ~]# cat /var/lib/jenkins/users/admin_6975698030007194989/config.xml
[root@jenkins ~]# grep -Ev "^$|^#" /etc/sysconfig/jenkins //去掉注释
JENKINS_HOME="/var/lib/jenkins" # jenkins主数据目录,数据备份,也只需要打包该文件即可
JENKINS_JAVA_CMD=""
JENKINS_USER="root" # 启动用户
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
JENKINS_PORT="8080" #启动端口
JENKINS_LISTEN_ADDRESS="" # 监听地址
JENKINS_HTTPS_PORT=""
JENKINS_HTTPS_KEYSTORE=""
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
JENKINS_HTTPS_LISTEN_ADDRESS=""
JENKINS_HTTP2_PORT=""
JENKINS_HTTP2_LISTEN_ADDRESS=""
JENKINS_DEBUG_LEVEL="5"
JENKINS_ENABLE_ACCESS_LOG="no"
JENKINS_ARGS=""
检查 jenkins 时间
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone','Asia/Shanghai')
三、访问 Jenkins 初始化页面
1.访问http://IP
:8080/
注意:
需要在安全组开放端口
2.获取admin密码
[root@jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
8aa6ae338cbb42b8b8385a33c4048267 //密码
修改Jenkins 密码
修改成功,会自动退出
Jenkins 如何安装插件
- 修改 jenkins 的插件下载源
- 在页面上导入jenkins插件
- 在服务器上,进行插件迁移
配置 jenkins 下载插件的代理
默认升级站点
https://updates.jenkins.io/update-center.json
清华源jenkins插件站点文章来源:https://www.toymoban.com/news/detail-625100.html
https://mirrors.tuna.tsinghua.edu.cn/jenkins/plugins/
修改jenkins的下载源配置
服务器 jenkins 插件导入文章来源地址https://www.toymoban.com/news/detail-625100.html
[root@jenkins ~]#tar -zxvf plugins。tar。gz
[root@jenkins ~]#cd plugins
[root@jenkins plugins]#mv ./* /var/lib/jenkins/plugins
[root@jenkins ~]#systemctl restart jenkins
到了这里,关于【Jenkins】Jenkins 安装的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!