jenkins配置Maven的私有仓库Nexus

1.什么是nexus?

  Neux:MAVEN的私有仓库;

  如果没有私服,我们所需的所有构件都需要通过maven的中央仓库和第三方的Maven仓库下载到本地,而一个团队中的所有人都重复的从maven仓库下载构件,不利于包的管理和共用.

Nexus的安装

2.x下载地址:https://help.sonatype.com/repomanager2/download
cd /data
wget https://download.sonatype.com/nexus/oss/nexus-2.13.0-01-bundle.tar.gz
cd nexus-2.13.0-01/bin
export RUN_AS_USER=root
./nexus start
echo "export RUN_AS_USER=root" >> /etc/profile
source /etc/profile
访问:http://{ip}:8081/nexus/
默认用户名密码 admin admin123

2.配置本地私有仓库

a.在仓库中,默认会在本地去查找插件,当未发现有插件时,会去第三方仓库查找,跟系统上的yum挺像!当本地内未能查找到相应的插件,会通过代理(proxy)类型进行下载插件,配置就在Central-->Remote Storage Location:https://repo1.maven.org/maven2/;

我们将其改为阿里云的maven远程仓库:http://maven.aliyun.com/nexus/content/groups/public/

b.配置完nexus,再去修改maven的settings配置

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>   
    <mirror>
      <id>lixiang</id>
      <mirrorOf>*</mirrorOf>
      <url>http://10.0.0.27:8081/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>
<profiles>
	<profile>
        <id>default</id>
            <repositories>
                <repository>
                    <id>public</id>
                    <url>http://10.0.0.27:8081/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
    </profile>
</profiles>
    <activeProfiles>
        <activeProfile>default</activeProfile>
    </activeProfiles>
</settings>

c.重启服务后,新建了一个在本地构建的的测试job:test-zrlog

参考博客:https://yq.aliyun.com/articles/485293

参考博客(这个博客我并没有做过,看着应该能走下去):http://blog.51cto.com/linuxg/1792086

原文地址:https://www.cnblogs.com/fawaikuangtu123/p/10327261.html