diff --git a/tasks/detect-task/detect-task.ps1 b/tasks/detect-task/detect-task.ps1 index e10b5cb..1662b8b 100644 --- a/tasks/detect-task/detect-task.ps1 +++ b/tasks/detect-task/detect-task.ps1 @@ -99,7 +99,15 @@ foreach ($AdditionalArgument in $ParsedArguments){ Write-Host "Downloading detect powershell library" $DetectDownloadSuccess = $false; try { + if ($UseProxy -eq $true){ + $ProxyCreds = New-Object System.Management.Automation.PSCredential( + ${Env:blackduck.hub.proxy.username}, + (ConvertTo-SecureString ${Env:blackduck.hub.proxy.password} -AsPlainText -Force) + ); + Invoke-RestMethod https://blackducksoftware.github.io/hub-detect/hub-detect.ps1?$(Get-Random) -Proxy ${Env:blackduck.hub.proxy.host}":"${Env:blackduck.hub.proxy.port} -ProxyCredential $ProxyCreds | Invoke-Expression; + } else { Invoke-RestMethod https://blackducksoftware.github.io/hub-detect/hub-detect.ps1?$(Get-Random) | Invoke-Expression; + } $DetectDownloadSuccess = $true; } catch [Exception] { Write-Host ("Failed to download the latest detect powershell library from the web. Using the embedded version.") diff --git a/tasks/detect-task/lib/detect.ps1 b/tasks/detect-task/lib/detect.ps1 index 803d71c..855495c 100644 --- a/tasks/detect-task/lib/detect.ps1 +++ b/tasks/detect-task/lib/detect.ps1 @@ -104,8 +104,7 @@ function Get-ProxyInfo () { Write-Host "Skipping proxy, no host found." }else{ Write-Host "Found proxy host." - $ProxyUrlBuilder = New-Object System.UriBuilder - $ProxyUrlBuilder.Host = $ProxyHost + $ProxyUrlBuilder = [UriBuilder]($ProxyHost) $ProxyPort = ${Env:blackduck.hub.proxy.port};