zoukankan      html  css  js  c++  java
  • gitlab+jenkens+maven私服

    软件版本:

    Maven:apache-maven-3.3.9-bin.tar

    JAVA:jdk-8u181-linux-x64.rpmNexus:nexus-3.13.0-01-unix.tar.gz

    1、在jenkins所在的服务器上安装maven&java

    rpm -ivh jdk-8u181-linux-x64.rpm

    tar -zxf apache-maven-3.3.9-bin.tar.gz
    mv apache-maven-3.3.9/ /usr/local/
    ln -s /usr/local/apache-maven-3.3.9/ /usr/local/maven
    echo "export PATH=/usr/local/maven/bin/:${PATH}"  >> /etc/profile
    source /etc/profile

    常用命令mvn -v  查看版本号mvn clean  清除上次编译结果mvn package  编译打包
    。。。

    2、创建Maven私服

    maven打包时默认是去官网下载依赖,速度会特别慢。可以通过创建本地仓库的方式加速

    私服分为两种:1、国内开源私服。2、自己搭建私服

    国内开源私服(以阿里云为例)

    更改maven的配置文件:/usr/local/maven/conf/settings.xml

    在<mirrors>里添加

        <mirror>
          <id>nexus-aliyun</id>
          <mirrorOf>central</mirrorOf>
          <name>Nexus aliyun</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>用mvn package再次打包的时候依赖就去阿里云寻找了。如果单独对某项目做私服的话,直接在项目下的pom.xml文件配置

    自己部署nexus私有仓库,在192.168.6.73上

    1、安装jdk。rpm -ivh jdk-8u181-linux-x64.rpm

    2、安装nexus

    tar -zxf nexus-3.13.0-01-unix.tar.gz
    mv nexus-3.13.0-01 /usr/local/
    ln -s /usr/local/nexus-3.13.0-01/ /usr/local/nexus
    echo "export PATH=/usr/local/nexus/bin/:${PATH}"  >> /etc/profile
    source /etc/profile

    启动nexus:/usr/local/nexus start

    http://192.168.6.73:8081  默认用户密码:admin/admin123

    配置nexus

    点设置-->仓库-->代理   将代理设置为阿里云然后最下面save保存

     

    复制public地址

     

    public组里面默认有三个仓库,不用动他。在maven的配置文件里会引用的到

    在maven的配置文件中更改配置

    <services>标签里配置认证

    <server>
        <id>my-nexus-releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>my-nexus-snapshot</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <mirrors>标签里配置私服地址

        <mirror>
          <id>nexus</id>
          <mirrorOf>*</mirrorOf>
          <url>http://192.168.6.73:8081/repository/maven-public/</url>    #之前复制的连接
        </mirror>
    <profiles>里写profile文件

               <profile>
                    <id>nexus</id>
                    <repositories>
                        <repository>
                            <id>central</id>
                            <url>http://192.168.6.73:8081/repository/maven-public/</url>
                            <releases>
                                <enabled>true</enabled>
                            </releases>
                            <snapshots>
                                <enabled>true</enabled>
                            </snapshots>
                        </repository>
                    </repositories>
                    <pluginRepositories>
                        <pluginRepository>
                            <id>central</id>
                            <url>http://192.168.6.73:8081/repository/maven-public/</url>
                            <releases>
                                <enabled>true</enabled>
                            </releases>
                            <snapshots>
                                <enabled>true</enabled>
                            </snapshots>
                        </pluginRepository>
                    </pluginRepositories>
                </profile>


    最后</settings>之前设置激活仓库

      <activeProfiles>
        <activeProfile>nexus</activeProfile>
      </activeProfiles>

    保存后再执行mvn package就会自动连接自己搭建的私服

    3、maven配合jenkins使用jenkins上创建maven项目在build内

     

     全局配置工具里配置maven的命令

     报错取消后点击立即构建试试。绿色正常,红色看报错信息。

  • 相关阅读:
    你好,2021!
    庚子走,辛丑来,愿一切安好!
    花魂鸟魂总难留,鸟自无言花自羞
    熟悉的小胡同
    夜半听鼾声
    写在儿子22岁生日
    vue配置Azure Artifacts npm包源
    RabbitMQ出错:AMQP close-reason, initiated by Peer, code=530的解决办法
    .NET MVC存储图片到数据库的解决方案
    EF Core解决报错’EntityTypeBuilder未包含“ToTable”的定义‘的方法
  • 原文地址:https://www.cnblogs.com/lingshu/p/13709064.html
Copyright © 2011-2022 走看看