jenkins是java编写的软件,如果要对java做编译打包操作maven和 jdk工具是必不可少的
软件官网
//jdk官方下载地址
https://www.oracle.com/cn/index.html
//官方下载地址
http://maven.apache.org/download.cgi
实际上我的下载地址
//jdk下载 需要登陆
https://www.oracle.com/java/technologies/downloads/#java8
//maven包下载
https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
//备用下载(自己的小破站,实在下不到就用这个)
wget http://101.43.4.210/devops/apache-maven-3.8.6-bin.tar.gz
wget http://101.43.4.210/devops/jdk-8u333-linux-x64.tar.gz
一、部署jdk和maven
cd /root #我软件包放在这里了
//解压缩
tar -zxvf apache-maven-3.8.6-bin.tar.gz
tar -zxvf jdk-8u333-linux-x64.tar.gz
//改名
mv jdk1.8.0_333/ jdk
mv apache-maven-3.8.6/ maven
二、修改maven配置
cd /root/maven
1、添加阿里云仓库
vi conf/settings.xml
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
注意在两个mirrors之间添加
2、设置maven用jdk编译的版本
vi conf/settings.xml
<profile>
<id>jdk8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
这个配置黏贴到最下面/profiles字段中,注意不要放在<-- --> 的范围内,这个是注释
3、启动jdk8的配置
vi conf/settings.xml
<activeProfiles>
<activeProfile>jdk8</activeProfile>
</activeProfiles>
开启配置,在最下面</settings> 这行之上添加一下配置
说明
后续使用jenkins在编译和打包jar包的时候会用到这两个工具,有两种方法调用
其实用起来差不多,为了方便我们使用第二种方法
1、直接将这两个目录直接通过build镜像打到jenkins镜像中
2、或者将jenkins的目录挂载出来,然后将服务cp 到持久化目录中,