搭建nexus上传jar包,并结合jenkins运行项目

一、搭建nexus

1、docker拉取镜像

需要将docker原更新一下

https://blog.csdn.net/qx020814/article/details/140908006?spm=1001.2014.3001.5502

bash 复制代码
docker pull sonatype/nexus3

创建nexus挂载文件、增加权限:

bash 复制代码
mkdir docker_nexus3
mkdir docker_nexus3/nexus-data
chown -R 200 docker_nexus3/nexus-data
chmod 777 docker_nexus3/nexus-data/

2、运行镜像

bash 复制代码
docker run -d --name=nuxus -v /docker_nexus3/nexus-data:/nexus-data -p 6000:6000 -p 8088:8081 sonatype/nexus3:latest

查看默认的admin密码:

cat docker_nexus3/nexus-data/admin.password

访问页面服务器ip:8088

没有登录时,只能查看数据

右上角登录后,就可以配置自己的仓库了

这里nexus默认创建了一个maven的仓库,分为四个:

使用Nexus3搭建Maven私服+上传第三方jar包到本地maven仓库 - Endv - 博客园 (cnblogs.com)

Hosted有三种方式,Releases、SNAPSHOT、Mixed

Releases: 一般是已经发布的Jar包

Snapshot: 未发布的版本

Mixed:混合的

3、添加jar包

我是直接在hosted 标识的仓库下添加jar包,添加后,会同步到group中:

我上班的时候,用第三方的私有jar包,老是看不见源码,也就没有注释,所以我这里专门去查了

如何吧源码加到仓库中:

(1)、增加一个打包源码的插件:

XML 复制代码
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

(2)、打包源码:

XML 复制代码
 mvn source:jar

然后就能在项目目标文件下查找到了:

写好唯一地址标识:

4、引用私有仓库jar包

修改Maven配置

XML 复制代码
  <servers>
<server>
    <id>my_maven</id>
    <username>admin</username>
    <password>123456</password>
</server>

  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |  -->
  <mirrors>
  
    <mirror>
     <id>my_maven</id>
     <mirrorOf>central</mirrorOf>
     <name>本地私有仓库</name>
     <url>http://192.168.126.160:8088/repository/maven-public/</url>
    </mirror>
	
  </mirrors>

分别是添加用户密码、设置仓库地址 id自定义、mirrorOf固定central、name自定义、url在nexus中复制:

然后和以前一样,引用jar包就可以了,但是这里要想查看源码,必须吧源码也引用一次,不知道为啥:

二、修改jenkis的maven配置文件

我这里直接查找了jenkins的maven地址,然后吧配置文件替换了,最简单、有效果的方法就是这个:

XML 复制代码
find / -name "settings.xml"

咱们刚开始运行docker的时候,把jenkins的文件挂载到宿主机上的,所以直接需改宿主机上的文件就好。

我本来是在jenkins网页端配置了,一直使用原配置文件,索性就把原配置文件给它改掉,我看它还报不报错!!

相关推荐
知已难寻6 小时前
Docker 入门:容器技术与 Docker 基础
java·运维·服务器·docker·云原生·容器
Alluxio13 小时前
Alluxio + OCI:为 AI 工作负载实现亚毫秒访问延迟与可扩展吞吐
运维·数据库·人工智能·分布式·缓存·ai·语言模型
Sayai17 小时前
Neo4j 图数据质量检查实战:环路检测、孤立节点与连通分量,两条 Cypher 引出的数据体检清单(含变长路径性能陷阱)
运维·neo4j·图数据库·数据质量·cypher
Elastic 中国社区官方博客18 小时前
更少的位数,相同的召回率:DiskBBQ 更保守的自动校准扫描
大数据·运维·开发语言·人工智能·elasticsearch·搜索引擎
方便面不加香菜18 小时前
Docker Volume -- 管理卷Volume详解
运维·docker·容器
沫璃染墨19 小时前
从零入门计算机网络系列(十八):TCP连接管理详解——从三次握手与四次挥手到TIME_WAIT机制
运维·服务器·网络·c++·网络协议·tcp/ip·tcp
Felven19 小时前
华为鲲鹏920s芯片serdestool工具使用说明
linux·运维·服务器·华为·鲲鹏920·serdestool
江湖有缘19 小时前
Docker实战 | 使用Docker部署lemonitor镜像站点列表程序
运维·docker·容器
莫晓燚19 小时前
mall 电商项目完整部署---实战
linux·运维·docker·容器
爱和冰阔落20 小时前
【Linux网络】JsonCpp 怎么实现序列化?从 Request/Response 到网络计算器消息设计
linux·运维·网络·php