从Nexus3导入制品

通过本指南可以将Snoatype Nexus3仓库中的制品包批量推送到阿里云packages仓库。

步骤一:下载迁移工具

工具下载地址:https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/artifact-migration-0.0.2-jar-with-dependencies.jar

通过上面地址将jar包下载到本地,保存为artifact-migration-jar-with-dependencies.jar。

步骤二:运行下载工具

请确保机器上安装了java8及以上版本,在当前jar包的目录下执行如下命令: 运行命令:java -jar artifact-migration-jar-with-dependencies.jar migrateNexus --help 可以查看帮助信息。

用例说明

java -jar artifact-migration-jar-with-dependencies.jar migrateNexus --help
Usage: migrate migrateNexus [-hV] [--dryrun] [--exclude=<exclude>]
                            [--include=<include>] --nexus-host=<nexusHost>
                            --source-repo-id=<repoId>
                            --source-repo-password=<repoPassword>
                            --source-repo-username=<repoUsername>
                            --target-repo-password=<repoPassword>
                            --target-repo-url=<repoUrl>
                            --target-repo-username=<repoUsername>
迁移nexus3制品
      --dryrun              试运行,不会真正上传包
      --exclude=<exclude>   排除的groupId,多个groupId以逗号分割
  -h, --help                Show this help message and exit.
      --include=<include>   包含的groupId,多个groupId以逗号分割
      --nexus-host=<nexusHost> nexus服务器地址
      --source-repo-id=<repoId> 源仓库Id
      --source-repo-password=<repoPassword> 访问源仓库的密码
      --source-repo-username=<repoUsername> 访问源仓库的用户名 
      --target-repo-password=<repoPassword> 访问目标仓库的密码,可在packages.aliyun.com中仓库指南中查看
      --target-repo-url=<repoUrl> 目标仓库地址,可在packages.aliyun.com中仓库指南中查看
      --target-repo-username=<repoUsername> 访问目标仓库的用户名,可在packages.aliyun.com中仓库指南中查看
  -V, --version             Print version information and exit.

如果帮助信息中中文出现乱码,可先在命令行中执行 chcp 65001,然后再执行java命令。

示例命令:

推送制品

  java -jar artifact-migration-jar-with-dependencies.jar  migrateNexus --source-repo-id="maven-releases" --source-repo-username="admin" --source-repo-password="admin123" --nexus-host="http://localhost:8081" --target-repo-url="https://packages.aliyun.com/6927b116e6c3e0425dbdf60d/maven/2624322-release-6f6h6r"  --target-repo-username="6927b0d679784350ec7aad16" --target-repo-password="************" --include="com.taobao.text"

这条命令会将指定的Nexus仓库maven-releases中groupId为com.taobao.text下的所有包上传到当前仓库中。

作者:Jeebiz  创建时间:2025-12-01 10:58
最后编辑:Jeebiz  更新时间:2025-12-11 13:19