解決同步多個jar文件上傳nexus的問題,創(chuàng)建文件upload.ps1。文件內(nèi)容如下:
# 配置參數(shù)
$nexusUrl = "https://nexus.abc.com/" # Nexus 地址
$repositoryName = "maven-hotel-releases" # 目標(biāo)倉庫名稱
$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)
# 構(gòu)建上傳 URL(替換路徑分隔符為 "/")
$uploadUrl = "$nexusUrl/repository/$repositoryName/$($relativePath.Replace('\', '/'))"
# 使用 curl 上傳文件
curl.exe -u "${username}:${password}" --upload-file "$filePath" $uploadUrl
Write-Host "Uploaded: $relativePath"
在cmd中運行該文件,就可以靜靜的看著它運行了。