Jenkins插件资源下载
Jenkins部署
Jenkins部署
#Jenkins主机安装OpenJDK环境
[root@Jenkins ~]# yum clean all; yum repolist -v
...
Total packages: 8,265
[root@Jenkins ~]# yum -y install java-11-openjdk-devel.x86_64 #安装OpenJDK11
[root@Jenkins ~]# ln -s /usr/lib/jvm/java-11-openjdk-11.0.15.0.9-2.el8_5.x86_64/ /usr/lib/jvm/jdk #创建JDK环境软链接
[root@Jenkins ~]# vim /etc/bashrc
[root@Jenkins ~]# tail -2 /etc/bashrc #声明JAVA_HOME环境变量
export JAVA_HOME="/usr/lib/jvm/jdk/"
export PATH=${JAVA_HOME}/bin/:$PATH
[root@Jenkins ~]# source /etc/bashrc #刷新当前bash环境
[root@Jenkins ~]# echo ${JAVA_HOME} #查看JAVA_HOME变量
/usr/lib/jvm/jdk/
[root@Jenkins ~]# which java
/usr/lib/jvm/jdk/bin/java
[root@Jenkins ~]# java -version
openjdk version "11.0.15" 2022-04-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)
[root@Jenkins ~]#
#安装工具相关软件
[root@Jenkins ~]# yum -y install git postfix #Git用于拉取代码、postfix用于发邮件
#安装Jenkins
[root@Jenkins ~]# ls jenkins-2.361.4-1.1.noarch.rpm
jenkins-2.361.4-1.1.noarch.rpm
[root@Jenkins ~]# yum -y localinstall ./jenkins-2.361.4-1.1.noarch.rpm #安装Jenkins
#启动Jenkins服务
[root@Jenkins ~]# systemctl enable jenkins.service #设置Jenkins开机自启动
[root@Jenkins ~]# systemctl start jenkins.service #启动Jenkins服务器
[root@Jenkins ~]# ss -antpul | grep java #确认8080端口被监听
tcp LISTEN 0 50 *:8080 *:* users:(("java",pid=13602,fd=8))
[root@Jenkins ~]#
Jenkins初使化
#获取Jenkins初始密码
[root@Jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
1aaf609acf3843a8aaf17e8b1f22e8ea
[root@Jenkins ~]#
#浏览器访问: http://192.168.88.30:8080/
离线部署Jenkins插件
#离线部署Jenkins插件
[root@Jenkins ~]# ls /var/lib/jenkins/plugins/ #空目录,没有任何插件
[root@Jenkins ~]# ls jenkins_plugins.tar.gz
jenkins_plugins.tar.gz
[root@Jenkins ~]# tar -xPpf jenkins_plugins.tar.gz -C / #解压Jenkins插件,保留文件归属
[root@Jenkins ~]# ls -l /var/lib/jenkins/plugins/ #确认该目录下文件归属
[root@Jenkins ~]# systemctl restart jenkins.service #重启Jenkins加载插件
[root@Jenkins ~]# ss -antpul | grep java
tcp LISTEN 0 50 *:8080 *:* users:(("java",pid=13917,fd=8))
#确认代码拉取情况
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/ #Jenkins工作目录
HIS-FONTEND
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/HIS-FONTEND/ #确认HIS-FONTEND代码拉取
favicon.ico index.html static
[root@Jenkins ~]# rm -rf /var/lib/jenkins/workspace/* #清理Jenkins工作目录
#确认代码拉取情况
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/ #Jenkins工作目录
HIS-FONTEND
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/HIS-FONTEND/ #确认拉取到子目录
HIS-FONTEND-v1
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/HIS-FONTEND/HIS-FONTEND-v1/
favicon.ico index.html static
[root@Jenkins ~]# rm -rf /var/lib/jenkins/workspace/* #清理Jenkins工作目录
#填写到Jenkins中HIS-FONTEND工程的构建过程shell语句
rm -rf .git #删除拉取到Jenkins本地目录中的版本库
tar -zcf fontend.tar.gz * #对代码进行打包操作
#确认HIS-FONTEND构建结果
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/
HIS-FONTEND
[root@Jenkins ~]# ls /var/lib/jenkins/workspace/HIS-FONTEND/ #目录下有代码tar包
favicon.ico fontend.tar.gz index.html static
[root@Jenkins ~]# rm -rf /var/lib/jenkins/workspace/* #清理Jenkins工作目录