Skip to content

Commit d406ef7

Browse files
committed
Updating cached version of detect. Removing hub where it does not break anything.
1 parent 9892a21 commit d406ef7

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

tasks/detect-task/lib/detect.ps1

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $EnvDetectFolder = Get-EnvironmentVariable -Key "DETECT_JAR_PATH" -DefaultValue
3131
$EnvTempFolder = Get-EnvironmentVariable -Key "TMP" -DefaultValue "";
3232
$EnvHomeTempFolder = "$HOME\tmp"
3333

34-
# If you want to pass proxy information, use detect environment variables such as 'blackduck.hub.proxy.host'
34+
# If you want to pass proxy information, use detect environment variables such as 'blackduck.proxy.host'
3535
# If you do pass the proxy information in this way, you do not need to supply it to detect as arguments.
3636
# Note: This script will not pick up proxy information from the passed 'detect arguments'
3737
# Note: This script will not pick up proxy information passed to the bash script using 'DETECT_CURL_OPTS'
@@ -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.4"
47+
$Version = "0.7.0"
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"
@@ -57,7 +57,14 @@ function Detect {
5757
Write-Host "Detect Powershell Script $Version"
5858

5959
if ($EnvDetectSkipJavaTest -ne "1"){
60-
Test-JavaExists
60+
if (Test-JavaNotAvailable){ #If java is not available, we abort early.
61+
$JavaExitCode = 127 #Command not found http://tldp.org/LDP/abs/html/exitcodes.html
62+
if ($EnvDetectExitCodePassthru -eq "1"){
63+
return $JavaExitCode
64+
}else{
65+
exit $JavaExitCode
66+
}
67+
}
6168
}else{
6269
Write-Host "Skipping java test."
6370
}
@@ -86,6 +93,16 @@ function Detect {
8693
}
8794
}
8895

96+
function Get-FirstFromEnv($Names) {
97+
foreach ($Name in $Names){
98+
$Value = Get-EnvironmentVariable -Key $Name -Default $null;
99+
if (-Not [string]::IsNullOrEmpty($Value)){
100+
return $Value;
101+
}
102+
}
103+
return $null;
104+
}
105+
89106
function Get-ProxyInfo () {
90107
$ProxyInfoProperties = @{
91108
'Uri'=$null
@@ -94,24 +111,15 @@ function Get-ProxyInfo () {
94111

95112
try {
96113

97-
$ProxyHost = ${Env:blackduck.hub.proxy.host};
98-
99-
if ([string]::IsNullOrEmpty($ProxyHost)){
100-
$ProxyHost = ${BLACKDUCK_HUB_PROXY_HOST};
101-
}
114+
$ProxyHost = Get-FirstFromEnv @("blackduck.proxy.host", "BLACKDUCK_PROXY_HOST", "blackduck.hub.proxy.host", "BLACKDUCK_HUB_PROXY_HOST");
102115

103116
if ([string]::IsNullOrEmpty($ProxyHost)){
104117
Write-Host "Skipping proxy, no host found."
105118
}else{
106119
Write-Host "Found proxy host."
107-
$ProxyUrlBuilder = New-Object System.UriBuilder
108-
$ProxyUrlBuilder.Host = $ProxyHost
120+
$ProxyUrlBuilder = New-Object System.UriBuilder -ArgumentList $ProxyHost
109121

110-
$ProxyPort = ${Env:blackduck.hub.proxy.port};
111-
112-
if ([string]::IsNullOrEmpty($ProxyPort)){
113-
$ProxyPort = ${Env:BLACKDUCK_HUB_PROXY_PORT};
114-
}
122+
$ProxyPort = Get-FirstFromEnv @("blackduck.proxy.port", "BLACKDUCK_PROXY_PORT", "blackduck.hub.proxy.port", "BLACKDUCK_HUB_PROXY_PORT");
115123

116124
if ([string]::IsNullOrEmpty($ProxyPort)){
117125
Write-Host "No proxy port found."
@@ -123,16 +131,8 @@ function Get-ProxyInfo () {
123131
$ProxyInfoProperties.Uri = $ProxyUrlBuilder.Uri
124132

125133
#Handle credentials
126-
$ProxyUsername = ${Env:blackduck.hub.proxy.username};
127-
$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-
}
134+
$ProxyUsername = Get-FirstFromEnv @("blackduck.proxy.username", "BLACKDUCK_PROXY_USERNAME", "blackduck.hub.proxy.username", "BLACKDUCK_HUB_PROXY_USERNAME");
135+
$ProxyPassword = Get-FirstFromEnv @("blackduck.proxy.password", "BLACKDUCK_PROXY_PASSWORD", "blackduck.hub.proxy.password", "BLACKDUCK_HUB_PROXY_PASSWORD");
136136

137137
if ([string]::IsNullOrEmpty($ProxyPassword) -or [string]::IsNullOrEmpty($ProxyUsername)){
138138
Write-Host "No proxy credentials found."
@@ -303,7 +303,7 @@ function Set-ToEscaped ($ArgArray){
303303
}
304304
}
305305

306-
function Test-JavaExists() {
306+
function Test-JavaNotAvailable() {
307307
Write-Host "Checking if Java is installed by asking for version."
308308
try {
309309
$ProcessStartInfo = New-object System.Diagnostics.ProcessStartInfo
@@ -322,8 +322,9 @@ function Test-JavaExists() {
322322
Write-Host "Java Standard Output: $StdOutput"
323323
Write-Host "Java Error Output: $StdError"
324324
Write-Host "Successfully able to start java and get version."
325+
return $FALSE;
325326
}catch {
326327
Write-Host "An error occurred checking the Java version. Please ensure Java is installed."
327-
exit 127 #Command not found http://tldp.org/LDP/abs/html/exitcodes.html
328+
return $TRUE;
328329
}
329-
}
330+
}

tasks/detect-task/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"demands": [],
1313
"version": {
1414
"Major": "1",
15-
"Minor": "0",
16-
"Patch": "4"
15+
"Minor": "1",
16+
"Patch": "0"
1717
},
1818
"minimumAgentVersion": "1.95.0",
1919
"instanceNameFormat": "Run Black Duck Detect for your build $(message)",

vsts-extension.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifestVersion": 1,
33
"id": "detect-for-tfs",
4-
"version": "1.0.4",
4+
"version": "1.1.0",
55
"name": "Black Duck Detect",
66
"publisher": "black-duck-software",
77
"public": true,
@@ -70,17 +70,17 @@
7070
},
7171
{
7272
"id": "blackduck-hub-endpoint",
73-
"description": "Service Endpoint for Black Duck Hub connections",
73+
"description": "Service Endpoint for Black Duck connections",
7474
"type": "ms.vss-endpoint.service-endpoint-type",
7575
"targets": [
7676
"ms.vss-endpoint.endpoint-types"
7777
],
7878
"properties": {
7979
"name": "blackduckhub",
80-
"displayName": "Black Duck Hub",
80+
"displayName": "Black Duck",
8181
"url": {
8282
"displayName": "Server URL",
83-
"helpText": "Provide the URL for your Black Duck Hub Server - please include the port if other than 80 (http) or 443 (https)"
83+
"helpText": "Provide the URL for your Black Duck Server - please include the port if other than 80 (http) or 443 (https)"
8484
},
8585
"authenticationSchemes": [
8686
{
@@ -89,7 +89,7 @@
8989
{
9090
"id": "username",
9191
"name": "Username",
92-
"description": "The username to access your Black Duck Hub instance",
92+
"description": "The username to access your Black Duck instance",
9393
"inputMode": "textbox",
9494
"validation": {
9595
"isRequired": true,
@@ -99,7 +99,7 @@
9999
{
100100
"id": "password",
101101
"name": "Password",
102-
"description": "The password to access your Black Duck Hub instance",
102+
"description": "The password to access your Black Duck instance",
103103
"inputMode": "passwordbox",
104104
"isConfidential": true,
105105
"validation": {
@@ -114,14 +114,14 @@
114114
},
115115
{
116116
"id": "blackduck-hub-proxy-endpoint",
117-
"description": "Proxy Service Endpoint for Black Duck Hub connections",
117+
"description": "Proxy Service Endpoint for Black Duck connections",
118118
"type": "ms.vss-endpoint.service-endpoint-type",
119119
"targets": [
120120
"ms.vss-endpoint.endpoint-types"
121121
],
122122
"properties": {
123123
"name": "blackduckproxy",
124-
"displayName": "Black Duck Hub Proxy",
124+
"displayName": "Black Duck Proxy",
125125
"url": {
126126
"displayName": "Server URL",
127127
"helpText": "Provide the URL for your proxy - please include the port if other than 80 (http) or 443 (https)"

0 commit comments

Comments
 (0)