安装jdk
解压jdk
mkdir /data
tar zxvf jdk-8u211-linux-x64.tar.gz -C /data/
添加环境变量
vim /etc/profile
最后一行添加
set java environment
JAVA_HOME=/data/jdk1.8.0_211/
JRE_HOME=/data/jdk1.8.0_211/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
重新加载环境变量
source /etc/profile
查看java版本
java -version
安装maven
解压
tar zxvf apache-maven-3.6.3-bin.tar.gz -C /data/
编辑环境变量
vi /etc/profile
最后一行添加
export MAVEN_HOME=/data/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
重新加载环境变量
source /etc/profile
查看mvn版本
# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /data/apache-maven-3.6.3
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /data/jdk1.8.0_211/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"
阿里云国内镜像
vi /data/apache-maven-3.6.3/conf/settings.xml
增加红色部分
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
下载安装
各个版本地址
https://pkg.jenkins.io/redhat-stable/
下载最新版本
wget https://pkg.jenkins.io/redhat-stable/jenkins-2.222.4-1.1.noarch.rpm
rpm -ivh jenkins-2.156-1.1.noarch.rpm
配置
vim /etc/sysconfig/jenkins
如果需要修改监听端口,请修改以下配置
JENKINS_PORT="8080"
配置权限
为了不因为权限出现各种问题,这里直接使用root
修改用户为root
vim /etc/sysconfig/jenkins
修改配置
JENKINS_USER="root"
修改目录权限
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
增加软链接,否则会启动失败。
ln -s /data/jdk1.8.0_211/bin/java /usr/bin/java
重启
systemctl restart jenkins
ps -ef | grep jenkins
安装向导
访问jenkins地址
http:<ip或者域名>:8080
执行命令查看密码:
cat /var/lib/jenkins/secrets/initialAdminPassword
插件安装选择推荐插件
插件安装完成以后将会创建管理员账户
安装完成:
后台页面
本文参考链接:
https://www.cnblogs.com/fangts/p/11095316.html