@@ -44,7 +44,7 @@ $EnvHomeTempFolder = "$HOME\tmp"
4444# heap size, you would set DETECT_JAVA_OPTS=-Xmx6G.
4545# $DetectJavaOpts = Get-EnvironmentVariable -Key "DETECT_JAVA_OPTS" -DefaultValue "";
4646
47- $Version = " 0.6.2 "
47+ $Version = " 0.6.4 "
4848
4949$DetectReleaseBaseUrl = " https://test-repo.blackducksoftware.com/artifactory/bds-integrations-release/com/blackducksoftware/integration/hub-detect"
5050$DetectSnapshotBaseUrl = " https://test-repo.blackducksoftware.com/artifactory/bds-integrations-snapshot/com/blackducksoftware/integration/hub-detect"
@@ -95,6 +95,11 @@ function Get-ProxyInfo () {
9595 try {
9696
9797 $ProxyHost = ${Env: blackduck.hub.proxy.host} ;
98+
99+ if ([string ]::IsNullOrEmpty($ProxyHost )){
100+ $ProxyHost = ${BLACKDUCK_HUB_PROXY_HOST} ;
101+ }
102+
98103 if ([string ]::IsNullOrEmpty($ProxyHost )){
99104 Write-Host " Skipping proxy, no host found."
100105 }else {
@@ -104,6 +109,10 @@ function Get-ProxyInfo () {
104109
105110 $ProxyPort = ${Env: blackduck.hub.proxy.port} ;
106111
112+ if ([string ]::IsNullOrEmpty($ProxyPort )){
113+ $ProxyPort = ${Env: BLACKDUCK_HUB_PROXY_PORT} ;
114+ }
115+
107116 if ([string ]::IsNullOrEmpty($ProxyPort )){
108117 Write-Host " No proxy port found."
109118 }else {
@@ -116,6 +125,14 @@ function Get-ProxyInfo () {
116125 # Handle credentials
117126 $ProxyUsername = ${Env: blackduck.hub.proxy.username} ;
118127 $ProxyPassword = ${Env: blackduck.hub.proxy.password} ;
128+
129+ if ([string ]::IsNullOrEmpty($ProxyUsername )){
130+ $ProxyUsername = ${BLACKDUCK_HUB_PROXY_USERNAME} ;
131+ }
132+
133+ if ([string ]::IsNullOrEmpty($ProxyPassword )){
134+ $ProxyPassword = ${BLACKDUCK_HUB_PROXY_PASSWORD} ;
135+ }
119136
120137 if ([string ]::IsNullOrEmpty($ProxyPassword ) -or [string ]::IsNullOrEmpty($ProxyUsername )){
121138 Write-Host " No proxy credentials found."
@@ -127,11 +144,11 @@ function Get-ProxyInfo () {
127144 $ProxyInfoProperties.Credentials = $ProxyCredentials ;
128145 }
129146
130- Write-Host " Succesfully setup proxy."
147+ Write-Host " Successfully setup proxy."
131148 }
132149
133150 } catch [Exception ] {
134- Write-Host (" An exception occured setting up the proxy, will continue but will not use a proxy." )
151+ Write-Host (" An exception occurred setting up the proxy, will continue but will not use a proxy." )
135152 Write-Host (" Reason: {0}" -f $_.Exception.GetType ().FullName);
136153 Write-Host (" Reason: {0}" -f $_.Exception.Message );
137154 Write-Host (" Reason: {0}" -f $_.Exception.StackTrace );
@@ -143,7 +160,27 @@ function Get-ProxyInfo () {
143160}
144161
145162function Invoke-WebRequestWrapper ($Url , $ProxyInfo , $DownloadLocation = $null ) {
146- return Invoke-WebRequest $Url - UseBasicParsing - OutFile $DownloadLocation - Proxy $ProxyInfo.Uri - ProxyCredential $ProxyInfo.Credentials
163+ $parameters = @ {}
164+ try {
165+ if ($DownloadLocation -ne $null ){
166+ $parameters.Add (" OutFile" , $DownloadLocation );
167+ }
168+ if ($ProxyInfo -ne $null ){
169+ if ($ProxyInfo.Uri -ne $null ){
170+ $parameters.Add (" Proxy" , $ProxyInfo.Uri );
171+ }
172+ if ($ProxyInfo.Credentials -ne $null ){
173+ $parameters.Add (" ProxyCredential" , $ProxyInfo.Credentials );
174+ }
175+ }
176+ }catch [Exception ] {
177+ Write-Host (" An exception occurred setting additional properties on web request." )
178+ Write-Host (" Reason: {0}" -f $_.Exception.GetType ().FullName);
179+ Write-Host (" Reason: {0}" -f $_.Exception.Message );
180+ Write-Host (" Reason: {0}" -f $_.Exception.StackTrace );
181+ }
182+
183+ return Invoke-WebRequest $Url - UseBasicParsing @parameters
147184}
148185
149186function Get-DetectSnapshotJar ($DetectFolder , $DetectVersion , $ProxyInfo ) {
0 commit comments