From 9cd6e34772d84b1a9916dd4157626862809b35a2 Mon Sep 17 00:00:00 2001 From: Kevin Still Date: Mon, 2 Apr 2018 14:24:26 -0600 Subject: [PATCH 1/2] Updating detect-task.ps1 to use the defined proxy to make its request to retrieve hub-detect.ps1. Updating detect.ps to not truncate the proxy address when you have a port associated with it. --- tasks/detect-task/detect-task.ps1 | 9 +++++++++ tasks/detect-task/lib/detect.ps1 | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tasks/detect-task/detect-task.ps1 b/tasks/detect-task/detect-task.ps1 index e10b5cb..0b49b3c 100644 --- a/tasks/detect-task/detect-task.ps1 +++ b/tasks/detect-task/detect-task.ps1 @@ -99,7 +99,16 @@ 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}; From 24f32c0873d456373d279b1808f2858c54fc5b00 Mon Sep 17 00:00:00 2001 From: Kevin Still Date: Mon, 2 Apr 2018 14:40:17 -0600 Subject: [PATCH 2/2] Fixing copy paste error --- tasks/detect-task/detect-task.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks/detect-task/detect-task.ps1 b/tasks/detect-task/detect-task.ps1 index 0b49b3c..1662b8b 100644 --- a/tasks/detect-task/detect-task.ps1 +++ b/tasks/detect-task/detect-task.ps1 @@ -107,8 +107,7 @@ try { 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.")