nexus在Linux上安装,本地仓库jar批量上传到nexus

一、下载地址

官网下载地址如下:

https://help.sonatype.com/en/download.html

或者直接下载最新版

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

二、直接安装

1. 将文件上传到目标文件夹/opt/nexus下解压

cd /opt/nexus
tar -zxvf nexus-3.69.0-02-java17-unix.tar.gz

2.配置

默认端口是8081,想改的话可以改成自己的

vi /opt/nexus/nexus-3.69.0-02/etc/nexus-default.properties

如果要允许root账户启动的话,将run_as_root改为false

vi /opt/nexus/nexus-3.69.0-02/bin/nexus

在这里插入图片描述

刷新一下配置

source /etc/profile

如果要修改内存的话

vi /opt/nexus/nexus-3.69.0-02/bin/nexus.vmoptions

在这里插入图片描述

3. 加入系统服务

创建用户和组

groupadd -r nexus-user
useradd -M -r -g nexus-user nexus-user
chown nexus-user:nexus-user /opt/nexus
vi /etc/systemd/system/nexus.service
[Unit]
Description=nexus
After=network.target
 
[Service]
User=root
Type=forking
Environment="JAVA_HOME=/etc/graalvm-ce-java17-22.3.1"
ExecStart=/opt/nexus/nexus-3.69.0-02/bin/nexus start
ExecStop=/opt/nexus/nexus-3.69.0-02/bin/nexus stop
 
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable nexus
systemctl start nexus

三、docker 安装

  • 安装
docker run -d --restart=always  --name nexus   -p 8081:8081   -v /etc/nexus:/nexus-data   sonatype/nexus3
  • 查找初始密码
find / -name admin.password

在这里插入图片描述

cat /var/lib/docker/volumes/1298675c5f3433bed00ff321e8e0be74ef6dcedf7341cc86b5db2e8ad3f2c5a9/_data/admin.password

显示的就是初始密码

四、将本地仓库jar批量上传到nexus

1.编写脚本放到本地仓库目录下

mavenimport.sh
#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
    case $opt in
        r) REPO_URL="$OPTARG"
        ;;
        u) USERNAME="$OPTARG"
        ;;
        p) PASSWORD="$OPTARG"
        ;;
    esac
done
 
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

2. 在当前目录打开git,输入以下内容执行

	./mavenimport.sh -u admin -p 123456 -r http://192.168.101.222/repository/maven-releases/

等待执行完即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值