Linux安装Jenkins

小柒博客 Jenkins评论6682字数 3283阅读10分56秒阅读模式

一、Jenkins介绍

Jenkins是一个开源软件项目,起源于Hudson(Hudson是商用的),是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件项目可以进行持续集成。

二、JDK安装

1)安装依赖包

[root@localhost ~]# yum -y install wget

2)下载安装包

[root@localhost ~]# wget https://repo.huaweicloud.com/java/jdk/11.0.2+9/jdk-11.0.2_linux-x64_bin.tar.gz

3)解压

[root@localhost ~]# tar xf jdk-11.0.2_linux-x64_bin.tar.gz -C /usr/local

[root@localhost ~]# chown -R root.root /usr/local/jdk-11.0.2

4)配置环境变量

[root@localhost ~]# vim /etc/profile

# 添加以下内容

export JAVA_HOME=/usr/local/jdk-11.0.2
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

5)查看java环境配置是否生效

[root@localhost ~]# source /etc/profile

[root@localhost ~]# java -version

java version "11.0.2" 2019-01-15 LTS

Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)

Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

三、Jenkins安装

1方式一

1)添加Jenkins官方Yum源

[root@localhost ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo

[root@localhost ~]# rpm --import https://pkg.jenkins.io/redhat/jenkins.io-2023.key

2)安装依赖包

[root@localhost ~]# yum -y install fontconfig tzdata-java

3)安装Jenkins

[root@localhost ~]# yum -y install jenkins

4)启动Jenkins

[root@localhost ~]# sed -i -e '/java-17-openjdk-amd64/s/#//' -e 's#/usr/lib/jvm/java-17-openjdk-amd64#/usr/local/jdk-11.0.2#' /usr/lib/systemd/system/jenkins.service

[root@localhost ~]# sed -i -e '/alternatives/s/#//' -e 's#/etc/alternatives#/usr/local/jdk-11.0.2/bin#' /usr/lib/systemd/system/jenkins.service

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl start jenkins

5)查看Jenkins服务状态

[root@localhost ~]# systemctl status jenkins

Linux安装Jenkins-图片1

2方式二

1)下载Jenkins安装包

[root@localhost ~]# wget https://mirrors.jenkins-ci.org/redhat/jenkins-2.422-1.1.noarch.rpm

2)安装Jenkins

[root@localhost ~]# yum -y install jenkins-2.422-1.1.noarch.rpm

3)启动Jenkins

[root@localhost ~]# sed -i -e '/java-17-openjdk-amd64/s/#//' -e 's#/usr/lib/jvm/java-17-openjdk-amd64#/usr/local/jdk-11.0.2#' /usr/lib/systemd/system/jenkins.service

[root@localhost ~]# sed -i -e '/alternatives/s/#//' -e 's#/etc/alternatives#/usr/local/jdk-11.0.2/bin#' /usr/lib/systemd/system/jenkins.service

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl start jenkins

4)查看Jenkins服务状态

[root@localhost ~]# systemctl status jenkins

3方式三

1)下载Tomcat

[root@localhost ~]# wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.gz

2)解压

[root@localhost ~]# tar xf apache-tomcat-8.5.93.tar.gz -C /usr/local

3)下载Jenkins(war包)

[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.422/jenkins.war

4)配置Tomcat

[root@localhost ~]# cd /usr/local/apache-tomcat-8.5.93/webapps/ROOT

[root@localhost ROOT]# rm -rf *

[root@localhost ROOT]# cp ~/jenkins.war .

[root@localhost ROOT]# jar xf jenkins.war

5)启动Tomcat

[root@localhost ROOT]# /usr/local/apache-tomcat-8.5.93/bin/startup.sh

4方式四

# Docker安装Jenkins

这里不在阐述,请参考博主另一篇文章(Docker安装Jenkins

访问地址:https://www.yangxingzhen.com/9511.html

5方式五

# Docker-Compose安装Jenkins

这里不在阐述,请参考博主另一篇文章(Docker-Compose安装Jenkins

访问地址:https://www.yangxingzhen.com/9533.html

四、Jenkins使用

1)访问Jenkins

# 浏览器输入http://192.168.36.200:8080,如下图所示

2)密码查看方式

[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword

5993f1242dd14fb2bc80c337b182c924

3)选择推荐插件

4)使用默认admin用户

5)配置Jenkins URL

6)修改admin密码

五、Jenkins安装常用插件

Git Parameter

用途:用户在构建时,让用户进行选择要构建的分支或tag

NodeJS

Email Extension Template

Extended Choice Parameter

六、全局工具配置

JAVA

Maven

Gradle

Nodejs

Linux安装Jenkins-图片2

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信公众号
微信扫一扫,关注我!
weinxin
小柒博客
  • 本文由 小柒博客 发表于 2023年9月6日13:41:43
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/9580.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证