1
Nexus 리포지토리에서 최신 아티팩트를 다운로드하려고합니다. 정확한 zip 파일 이름을 지정하면 정상적으로 작동합니다. 일반 URL (REST URI)을 사용하여 다운로드하려고하면 Unauthorized 401이 표시됩니다. 나는 Invoke-WebRequest
, WebClient
및 Invoke-RestMethod
도 시도했습니다.Nexus 아티팩트 다운로드를 위해 PowerShell DownloadFile()이 작동하지 않습니다.
$wc = New-Object System.Net.WebClient
$URL = "http://nexusrepo/nexus/service/local/artifact/maven/redirect?r=my-snapshot&g=my.group.id&a=my.artifact.id&v=1.10.0-SNAPSHOT&c=win32.win32.x86_64&p=zip"
$username = "nexus"
$password = "nexus"
$auth = $username + ":" + $password
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
$EncodedPassword = [System.Convert]::ToBase64String($Encoded)
$wc.Headers.Add("Accept-Encoding", "gzip,deflate")
$wc.Credentials = New-Object System.Net.NetworkCredential($username, $password)
$wc.Headers.Add("Authorization", "Basic " + $EncodedPassword)
$wc.UseDefaultCredentials = $false
$wc.DownloadFile($URL, "MyApp.zip")
Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (401) Unauthorized." At C:\temp\NexusDownloadTest\Nexus-Download.ps1:39 char:1 + $weburl = $wc.DownloadString($URL) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WebException
사람이 나를 도와 주실 수 있습니까?
Nexus 서버의 로그에 무엇인가가 표시 되나요? –
Nexus 서버의 로그에 액세스 할 수 없습니다. –
아직도 대답을 찾고 있습니다. 헤더 정보가 리디렉션되면 손실됩니다. PowerShell의 리디렉션 된 URL에 머리글 정보를 다시 설정하는 방법은 무엇입니까? 누군가가 나를 도울 수 있다면 그것을 고맙게 생각합니다. –