解决同步多个jar文件上传nexus的问题,创建文件upload.ps1。文件内容如下:
# 配置参数
$nexusUrl = "https://nexus.abc.com/" # Nexus 地址
$repositoryName = "maven-hotel-releases" # 目标仓库名称
$username = "jack" # Nexus 账号
$password = "123456" # Nexus 密码
$localRepoPath = "E:\mavenRepository" # 本地仓库文件夹路径
# 遍历本地仓库文件夹
Get-ChildItem -Path $localRepoPath -Recurse -File | ForEach-Object {
$filePath = $_.FullName
$relativePath = $filePath.Substring($localRepoPath.Length + 1)
# 构建上传 URL(替换路径分隔符为 "/")
$uploadUrl = "$nexusUrl/repository/$repositoryName/$($relativePath.Replace('\', '/'))"
# 使用 curl 上传文件
curl.exe -u "${username}:${password}" --upload-file "$filePath" $uploadUrl
Write-Host "Uploaded: $relativePath"
在cmd中运行该文件,就可以静静的看着它运行了。