jenkins安装及配置
Posted wliy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jenkins安装及配置相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# rz -E
rz waiting to receive.
[[email protected] ~]# 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
[[email protected] ~]# tar xf apache-maven-3.3.9-bin.tar.gz
[[email protected] ~]# 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
[[email protected] ~]# mv apache-maven-3.3.9 /usr/local/
[[email protected] ~]# ln -s /usr/local/apache-maven-3.3.9/ /usr/local/maven
[[email protected] ~]# /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"
[[email protected] ~]# export PATH=/usr/local/apache-maven-3.3.9/bin/:$PATH
[[email protected] ~]# vim /etc/profile
[[email protected] ~]# 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"
[[email protected] ~]# rz -E
rz waiting to receive.
[[email protected] ~]# ls hello-world.tar.gz
hello-world.tar.gz
[[email protected] ~]# tar xf hello-world.tar.gz
[[email protected] ~]# 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
[[email protected] ~]# cd hello-world/ #一定要进目录在操作 不然会报错
[[email protected] ~]# 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] ------------------------------------------------------------------------
[[email protected] 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
[[email protected] hello-world]# ls
pom.xml src target
[[email protected] hello-world]# mvn clean
[[email protected] hello-world]# ls
pom.xml src
[[email protected] hello-world]# mvn test
[[email protected] hello-world]# ls
pom.xml src target
[[email protected] ~]# 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...
[[email protected] ~]# tar xf nexus-3.13.0-01-unix.tar.gz
#安装jkd
[[email protected] ~]# 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...
[[email protected] ~]# tar xf nexus-3.13.0-01-unix.tar.gz
[[email protected] ~]# mv nexus-3.13.0-01 /usr/local/
[[email protected] ~]# ln -s /usr/local/nexus-3.13.0-01/ /usr/local/nexus
[[email protected] ~]# /usr/local/nexus/bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
[[email protected] ~]# ss -lntup|grep java
[[email protected] ~]# /usr/local/nexus/bin/nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
nexus is running.
# 没有端口就加大虚拟机内存3G
[[email protected] ~]# 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_jenkinsgitlab_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
以上是关于jenkins安装及配置的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7 安装配置 jenkins 及 自动从gitlab上拉取代码自动打包并发布到远程tomcat服务器
JenKins结合cppcheck及cpplint进行代码风格及静态代码检测
Jenkins——持续集成介绍及Jenkins安装部署(插件+用户权限+凭据+Maven打包)