Gitlab+Jenkins学习之路(十二)之Maven的私有仓库Nexus
2023-09-27 14:29:14 时间
-
1、什么是Nexus?
在前面进行maven项目的构建中,可以看到在构建的过程中需要安装maven的依赖插件,如图:
而在maven的默认配置中是在官网的中央仓库和第三方的maven仓库进行下载,速度偏慢。这里提供阿里云的maven插件库(http://maven.aliyun.com/nexus/#view-repositories),可以在/data/apache-maven-3.5.2/conf/settings.xml 配置文件中进行修改。
在日常的开发构建中,我们也可以自己搭建一个私有的nexus。那么什么是nexus呢?
Nexus是maven的私有仓库;
如果没有nexus,项目的打包都需要在公网下载,不利于包的管理和共用;
如果没有私有仓库,我们所需要的所有构件都需要通过maven的中央仓库和第三方的maven仓库下载到本地,而一个团队的所有人都需要重复地从maven仓库中下载构件。
-
2、Nexus的安装
(1)下载Nexus [root@linux-node2 ~]# wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz --2017-12-25 10:45:42-- https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz Resolving sonatype-download.global.ssl.fastly.net (sonatype-download.global.ssl.fastly.net)... 151.101.228.249 Connecting to sonatype-download.global.ssl.fastly.net (sonatype-download.global.ssl.fastly.net)|151.101.228.249|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 73187012 (70M) [application/octet-stream] Saving to: ‘nexus-2.14.5-02-bundle.tar.gz’ 5% [=======> ] 4,375,805 76.4KB/s eta 12m 59s (2)解压Nexus [root@linux-node2 ~]# tar -zxvf nexus-2.14.5-02-bundle.tar.gz [root@linux-node2 ~]# mv nexus-2.14.5-02 sonatype-work /data/ (3)启动Nexus [root@linux-node2 ~]# cd /data/nexus-2.14.5-02 [root@linux-node2 nexus-2.14.5-02]# ls bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp [root@linux-node2 nexus-2.14.5-02]# cd bin/ [root@linux-node2 bin]# ./nexus start **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script. [root@linux-node2 bin]# export RUN_AS_USER=root [root@linux-node2 bin]# ./nexus start **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Starting Nexus OSS... Started Nexus OSS. [root@linux-node2 bin]# netstat -tulnp |grep 8081 tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 4773/java (4)浏览器访问仓库 浏览器访问:http://192.168.56.12:8081/nexus,如图:
点击右上角"login" 默认用户名密码:admin ,admin123
在仓库中,默认会在本地去查找插件,当未发现有插件时,会通过第三方仓库查到,这些仓库的类型都是hosts类型,也就是在本机进行查询。
当本地内未能查找到相应的插件,会通过代理(proxy)类型进行下载插件,配置就在Central——>Remote Storage Location(回源地址),这里我们填写阿里云的maven远程仓库进行下载
http://maven.aliyun.com/nexus/content/groups/public/
配置完成nexus后,在修改maven的settings配置
[root@linux-node2 ~]# vim /data/apache-maven-3.5.2/conf/settings.xml 将其中的仓库链接地址修改为: http://192.168.56.12:8081/nexus/content/groups/public/
这样在构建时,首次会从阿里云的maven仓库中下载插件,后面再次重新下载插件时会从本地进行下载
相关文章
- 在Jenkins中集成Sonarqube
- Python接口测试实战之Git及Jenkins持续集成
- Jenkins打包Gitlab代码发布到远程Linux服务器
- Web API 持续集成:PostMan+Newman+Jenkins(图文讲解)
- 程序人生:是不是Jenkins大神,看这几个技巧就够
- Jenkins错误amass
- 阿里内网最新实战手册,7 大核心组件详解 SpringCloud+Jenkins+K8S
- Jenkins(持续集成)Windows版本解决插件安装缓慢
- centos8.2安装jenkins
- jenkins 用法示例
- jenkins和gitlab版本
- jenkins:忘记密码怎么办
- Jenkins Pipeline+Maven+Gitlab持续集成构建
- selenium+jenkins+maven+testNG搭建持续集成环境
- Jenkins docker 一键发布 (一)
- jenkins构建maven项目:找不到本地依赖包的解决办法
- 【持续集成】centos+jenkins+git+maven,-bash: git: command not found报错处理
- jenkins构建,拉取不到最新版本代码,报clock of the subversion server appears to be out of sync
- jenkins实战(二):构建自由风格的maven项目
- 如何在jenkins的maven项目中,用mvn命令行指定findbugs的黑名单规则文件