2. 部署Jenkins:
[root@node2 ~]# tar xf jdk-8u231-linux-x64.tar.gz -C /usr/local/
[root@node2 ~]# tar xf apache-tomcat-9.0.36.tar.gz
[root@node2 ~]# mv apache-tomcat-9.0.36 /usr/local/tomcat
# 配置环境变量:
vim /etc/profile
...省略部分内容
export JAVA_HOME=/usr/local/jdk1.8.0_231
export PATH=/usr/local/jdk1.8.0_231/bin:$PATH
# 使变量生效:
[root@node2 ~]# . /etc/profile
# 验证,看到Java的版本信息则表示配置成功:
[root@node2 ~]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
# 启动tomcat:
[root@node2 ~]# wget -c https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/latest/jenkins.war
[root@node2 ~]# rm -rf /usr/local/tomcat/webapps/ROOT/*
[root@node2 ~]# unzip jenkins.war -d /usr/local/tomcat/webapps/ROOT/
[root@node2 ~]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8.0_231
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
2.1 访问web:
访问75.122:8080,解锁Jenkins:
[root@node2 ~]# cat /root/.jenkins/secrets/initialAdminPassword
eb5f66f12d0948c2b13e2ac946baf3dc
2.2 选择插件安装:
Jenkins的插件下载地址默认是外网地址,下载速度会比较慢,可以先跟换源地址,在进行需要下载。所以这一步可以先选择插件安装:
# 换源:
[root@node2 ~]# sed -i -e 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' -e 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' /root/.jenkins/updates/default.json
2.2 安装插件:
安装git、Deploy to container等插件。git插件用于从gitlab拉取代码,Deploy to container插件用于将构建的war包部署到tomcat服务。
2.3 配置maven:
[root@node2 ~]# wget -c --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz
[root@node2 ~]# tar xf apache-maven-3.8.3-bin.tar.gz
[root@node2 ~]# mv apache-maven-3.8.3 /usr/local/maven
# 配置环境变量:
[root@node2 ~]# vim /etc/profile
...
export JAVA_HOME=/usr/local/jdk1.8.0_231
export MAVEN_HOME=/usr/local/maven
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
# 使配置生效:
[root@node2 ~]# . /etc/profile
# 验证mvn:
[root@node2 ~]# mvn -v
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/maven
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8.0_231/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1062.el7.x86_64", arch: "amd64", family: "unix"
2.4 配置jdk/maven环境:
2.5 添加环境变量:
2.6 修改maven的仓库:
[root@node2 ~]# mkdir -p /usr/local/repo
[root@node2 ~]# vim /usr/local/maven/conf/settings.xml
...
<localRepository>/usr/local/repo</localRepository>
...
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
...
欢迎点赞,收藏,你的喜欢就是我原创的动力,Jenkins系列将会持续更新。
如果获取最新文章更新,以及常用软件,可以关注公众号: 运维朱工