Linux下持续集成环境之Maven私服搭建

Linux下持续集成环境之Maven私服搭建

Apache软件下载地址: http://mirror.bit.edu.cn/apache/
文章来源:https://blog.csdn.net/omsvip/article/details/80295338


Maven安装

1、Maven下载地址,这里安装http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.3/binaries/
2、解压到服务器目录,并重命名为maven3

tar zvxf apache-maven-3.5.3-bin.tar.gz

3、配置环境变量

vi /etc/profile 编辑系统配置文件

export MAVEN_HOME=/usr/local/maven3
export PATH=$MAVEN_HOME/bin:$PATH

source /etc/profile 使配置生效


Nexus安装

下载nexus,下载2.x版本,地址:https://www.sonatype.com/download-oss-sonatype
在服务器解压后修改配置文件中的端口地址,这里修改为9091

在文件目录:~/nexus/nexus-2.14.8-01/conf/nexus.properties

启动nexus

vi /etc/profile 添加
export RUN_AS_USER=root #root用户启动
source /etc/profile

使用命令在目录~/nexus/nexus-2.14.8-01/bin 中启动

./nexus start | stop | restart

打开地址登录
http://maven.xxx.com/nexus/#welcome

修改密码、配置server参数

点击菜单server配置URL
User Agent Customization:http://maven.xxx.com/nexus
Base URL:http://maven.xxx.com/nexus
Force Base URL 此处勾选
保存


配置Nginx代理

server {
    listen       80;
    server_name  maven.xxx.com;

    location / {
        proxy_pass http://maven.xxx.com:9091; 
    }
}

完成以上操作后,Maven私有库地址为http://maven.xxx.com/nexus


项目中具体使用

1、本地使用私有库Maven配置

<mirror>
    <id>nexus</id>
    <name>xxx maven</name>
    <url>http://maven.xxx.com/nexus/content/groups/public/</url> 
    <mirrorOf>*</mirrorOf> 
</mirror>

2项目中单独使用:

<repositories>
    <repository>
         <id>Public Repositories</id>
         <name>nexus</name>
         <url>http://maven.xxx.com/nexus/content/groups/public/</url>
     </repository>
</repositories>

3、本地打包到私有库Maven配置

settings.xml配置文件添加:

<server>  
 <id>nexus-releases</id>  
  <username>adminxxx</username>  
  <password>adminxxx</password>  
</server>
<server>
  <id>nexus-snapshots</id>
  <username>adminxxx</username>
  <password>adminxxx</password>
</server>

项目中部署配置:

<distributionManagement>
    <!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致 -->
    <repository>
        <id>nexus-releases</id>
        <name>Nexus Release Repository</name>
        <url>http://maven.xxx.com/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <name>Nexus Snapshot Repository</name>
        <url>http://maven.xxx.com/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

第三方jar上传


操作步骤

1.第一步:登录nexus Maven库管理系统;
2.第二步:选中 “repositories”,进入仓库界面;
3.第三步:选择 “3rd party”,进入第三方仓库管理界面;
4.第四步:选择 “Artifact Upload”标签,进入第三方包添加界面;
Auto guess默认选中 ,点击”select Artifact(s) for upload”后 ,所以如果jar包有自己的版本,系统会自动抓取GAV Definition Source的相关信息 ;
5.第五步,补充/填写信息。注意修改group信息;
6.第六步:点击“add artifact”:
7.第七步:点击“upload artifact(s)”:
8.使用方法:在browse Index标签中,点击”refresh”后,选择刚才上传的第三方包,右边出现pom引用的xml文件定义,加入到项目中的pom文件中即可.

文章来源:

本文地址:https://blog.csdn.net/omsvip/article/details/80295338

猜你喜欢

转载自blog.csdn.net/rzg813/article/details/80295338