君玉自牧 君玉自牧
首页
  • Linux
  • Nginx
  • MySQL
  • Redis
  • Kafka
  • Docker
  • Jenkins
  • Oneindex
  • Bitwarden
  • Confluence
  • Photogallery
  • 智能手机
  • 上古卷轴
  • 健身记录
  • 站点相关
  • 未完待续
GitHub (opens new window)
首页
  • Linux
  • Nginx
  • MySQL
  • Redis
  • Kafka
  • Docker
  • Jenkins
  • Oneindex
  • Bitwarden
  • Confluence
  • Photogallery
  • 智能手机
  • 上古卷轴
  • 健身记录
  • 站点相关
  • 未完待续
GitHub (opens new window)
  • 技术架构

  • 桌面维护

  • 网络工程

  • 系统运维

  • 环境搭建

  • 容器编排

  • 持续集成

    • Nexus Repository 制品库
      • 服务搭建
      • 仓库创建
      • 批量上传
      • 仓库引用
    • Gitlab 部署 & 服务配置
    • Jenkins 部署 & 服务配置
    • Sonarqube 部署 & 服务配置
    • 用 Jenkins 构建 .NET 项目
    • 用 Jenkins 构建 VUE 项目
    • 用 Jenkins 构建 Java 项目
  • 监控告警

  • 项目实践

  • 脚本开发

  • 前端开发

  • 后端开发

  • 效率工具

目录

Nexus Repository 制品库

Nexus Repository (opens new window) 分为 OSS 版和 PRO 版,其中 OSS 版本免费使用,提供对制品的常规存储功能;安全扫描、高可用、用户权限等高级功能,需要付费(PRO 版本)使用 image.png Nexus 可以配置 3 种类型的仓库,分别是:proxy、hosted 和 group

  • 代理仓库(proxy):代理远程公共仓库,如 Maven 中央仓库
  • 本地仓库(hosted):该仓库通常用来部署本地项目所产生的构件
  • 仓库组(group):顾名思义,聚合上述两个种仓库统一提供服务

图-Nexus.drawio.png

# 服务搭建

官网下载 (opens new window)并上传至服务器

#没有外网手动下载
wget https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.42.0-01-unix.tar.gz
tar xvzf nexus-3.42.0-01-unix.tar.gz
mv nexus-3.42.0-01 /app/service/nexus
cd /app/service/nexus
#前台运行
./bin/nexus run
#后台运行
. /bin/nexus start stop restart force-reload status
1
2
3
4
5
6
7
8
9

# 仓库创建

浏览器访问 http://128.160.30.236:8081/ (opens new window),点击右上角“Sign in”进行登录 image.png 账户:admin 密码:admin123 登录后依次点击“齿轮”->“Repositories”
image.png

点击“Create Repository”
image.png

选择 maven2(hosted)
image.png

依次填入库名跟选择下图红框位置的参数
image.png

点击“Create Repository”完成私有仓库创建,找到并打开刚创建的仓库,获取 URL

# 批量上传

把创建上传 Shell 脚本(vi mavenimport.sh)存放到 maven 同目录下

#!/bin/bash
#将脚本拷贝到 Maven 本地目录下,不熟悉命令请不要修改脚本名称

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}/{} ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

再一同上传至 Linux 服务器,如下图: image.png 进入目录,给脚本添加可执行权限:chmod +x mavenimport.sh 然后执行:./mavenimport.sh -u admin -p admin123 -r URL 命令,URL 替换为上述步骤创建的 Maven 私有仓库地址。 等待上传脚本跑完,浏览器访问 http://ip:8081/#browse/browse:smcp 查看

# 仓库引用

  • setting.xml:Maven 全局配置文件
  • pom.xml:本地项目配置文件

使用 setting.xml 文件引用

<servers>
        <server>
            <id>smcp</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <server>
            <id>smcp-snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
  </servers>

<profiles>
	<profile>
		<id>smcp</id>
		<repositories>
			<repository>
				<id>smcp</id>
				<url>http://128.160.30.236:8081/repository/smcp/</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
		<pluginRepositories>
			<pluginRepository>
				<id>smcp</id>
				<url>http://128.160.30.236:8081/repository/smcp/</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
	</profile>
</profiles>

<activeProfiles>
	<activeProfile>smcp</activeProfile>
</activeProfiles>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
网页编辑 (opens new window)
最近提交: 2023/03/22, 11:52:35
Kubernetes 使用故障
Gitlab 部署 & 服务配置

← Kubernetes 使用故障 Gitlab 部署 & 服务配置→

Theme by Vdoing | Copyright © 2011-2023 | 君玉自牧
粤ICP备15057965号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式