jenkins安装及配置
[root@jenkins ~]# rz -E
rz waiting to receive.
[root@jenkins ~]# ls
anaconda-ks.cfg git_data jenkins-2.99-1.1.noarch.rpm ssh164.exp y
apache-maven-3.3.9-bin.tar.gz jdk-8u181-linux-x64.rpm monitor ssh164.sh y.pub
[root@jenkins ~]# tar xf apache-maven-3.3.9-bin.tar.gz
[root@jenkins ~]# ls
anaconda-ks.cfg git_data monitor y
apache-maven-3.3.9 jdk-8u181-linux-x64.rpm ssh164.exp y.pub
apache-maven-3.3.9-bin.tar.gz jenkins-2.99-1.1.noarch.rpm ssh164.sh
[root@jenkins ~]# mv apache-maven-3.3.9 /usr/local/
[root@jenkins ~]# ln -s /usr/local/apache-maven-3.3.9/ /usr/local/maven
[root@jenkins ~]# /usr/local/maven/bin/mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/maven
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_181-amd64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
[root@jenkins ~]# export PATH=/usr/local/apache-maven-3.3.9/bin/:$PATH
[root@jenkins ~]# vim /etc/profile
[root@jenkins ~]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/apache-maven-3.3.9
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_181-amd64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
[root@jenkins ~]# rz -E
rz waiting to receive.
[root@jenkins ~]# ls hello-world.tar.gz
hello-world.tar.gz
[root@jenkins ~]# tar xf hello-world.tar.gz
[root@jenkins ~]# tree hello-world
hello-world
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── juvenxu
│ └── mvnbook
│ └── helloworld
│ └── HelloWorld.java
└── test
└── java
└── com
└── juvenxu
└── mvnbook
└── helloworld
└── HelloWorldTest.java
13 directories, 3 files
[root@jenkins ~]# cd hello-world/ #一定要进目录在操作 不然会报错
[root@jenkins ~]# mvn package
等好久 会请求官网下载包 ......
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:37 min
[INFO] Finished at: 2018-11-19T09:33:32+08:00
[INFO] Final Memory: 17M/42M
[INFO] ------------------------------------------------------------------------
[root@jenkins hello-world]# ll ~/.m2/repository/
总用量 0
drwxr-xr-x 6 root root 70 11月 19 09:33 asm
drwxr-xr-x 3 root root 38 11月 19 09:32 backport-util-concurrent
drwxr-xr-x 3 root root 25 11月 19 09:31 classworlds
drwxr-xr-x 3 root root 20 11月 19 09:31 com
drwxr-xr-x 3 root root 25 11月 19 09:31 commons-cli
drwxr-xr-x 3 root root 26 11月 19 09:33 commons-lang
drwxr-xr-x 3 root root 33 11月 19 09:32 commons-logging
drwxr-xr-x 3 root root 18 11月 19 09:33 jdom
drwxr-xr-x 3 root root 19 11月 19 09:31 junit
drwxr-xr-x 3 root root 19 11月 19 09:32 log4j
drwxr-xr-x 6 root root 65 11月 19 09:32 org
[root@jenkins hello-world]# ls
pom.xml src target
[root@jenkins hello-world]# mvn clean
[root@jenkins hello-world]# ls
pom.xml src
[root@jenkins hello-world]# mvn test
[root@jenkins hello-world]# ls
pom.xml src target
[root@web01 ~]# rpm -ivh jdk-8u181-linux-x64.rpm
警告:jdk-8u181-linux-x64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:jdk1.8-2000:1.8.0_181-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@web01 ~]# tar xf nexus-3.13.0-01-unix.tar.gz
#安装jkd
[root@web01 ~]# rpm -ivh jdk-8u181-linux-x64.rpm
警告:jdk-8u181-linux-x64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:jdk1.8-2000:1.8.0_181-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@web01 ~]# tar xf nexus-3.13.0-01-unix.tar.gz
[root@web01 ~]# mv nexus-3.13.0-01 /usr/local/
[root@web01 ~]# ln -s /usr/local/nexus-3.13.0-01/ /usr/local/nexus
[root@web01 ~]# /usr/local/nexus/bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
[root@web01 ~]# ss -lntup|grep java
[root@web01 ~]# /usr/local/nexus/bin/nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
nexus is running.
# 没有端口就加大虚拟机内存3G
[root@web01 ~]# ss -lntup| grep 8081
tcp LISTEN 0 50 *:8081 *:* users:(("java",pid
配置Maven全局配置文件 (在jenkins机器上)
/usr/local/maven/conf/settings.xml
#打开 nexus.txt文件 照改
131 </server>
132 -->
133 <server>
134 <id>my-nexus-releases</id>
135 <username>admin</username>
136 <password>admin123</password>
137 </server>
138 <server>
139 <id>my-nexus-snapshot</id>
140 <username>admin</username>
141 <password>admin123</password>
142 </server>
143 </servers>
E:\课堂记录\day74 gitlab_jenkins\gitlab_jenkins/settings.xml
http://192.168.137.202:8081/repository/maven-public
配置完
mvn clean
mvn package
如果失败
删除 /root/.m2 立马执行mvn package
似乎就比较稳了。
配置仓库两个选项
1、项目下的pom.xml配置、只生效当前的项目
2、在maven配置全局所有项目生效
上传JDK和nexus安装包
rpm -ivh jdk-8u121-linux-x64.rpm
mv nexus-3.13.0-01 /usr/local/
ln -s /usr/local/nexus-3.13.0-01 /usr/local/nexus
/usr/local/nexus/bin/nexus start
10.0.0.202:8081 admin admin123
配置Maven全局配置文件
/usr/local/maven/conf/settings.xml
想要体面生活,又觉得打拼辛苦;想要健康身体,又无法坚持运动。人最失败的,莫过于对自己不负责任,连答应自己的事都办不到,又何必抱怨这个世界都和你作对?人生的道理很简单,你想要什么,就去付出足够的努力。