Skip to content

Commit

Permalink
Updating phone home
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichard committed Nov 16, 2017
1 parent f1d474f commit 0c0f06c
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;

import org.apache.commons.lang3.StringUtils;
import org.apache.tools.ant.types.Commandline;
Expand Down Expand Up @@ -83,6 +84,8 @@ public void runCommonDetectStep(final String detectProperties) {
final CIEnvironmentVariables variables = new CIEnvironmentVariables();
variables.putAll(envVars);
logger.setLogLevel(variables);
PhoneHomeDataService phoneHomeDataService = null;
Future<Boolean> phoneHomeTask = null;
try {
final String pluginVersion = PluginHelper.getPluginVersion();
logger.info("Running Jenkins Detect version : " + pluginVersion);
Expand Down Expand Up @@ -142,7 +145,7 @@ public void runCommonDetectStep(final String detectProperties) {
final HubServerConfig hubServerConfig = hubServerConfigBuilder.build();
final RestConnection restConnection = hubServerConfig.createCredentialsRestConnection(logger);
final HubServicesFactory servicesFactory = new HubServicesFactory(restConnection);
final PhoneHomeDataService phoneHomeDataService = servicesFactory.createPhoneHomeDataService();
phoneHomeDataService = servicesFactory.createPhoneHomeDataService();

final String thirdPartyVersion = Jenkins.getVersion().toString();

Expand All @@ -152,7 +155,7 @@ public void runCommonDetectStep(final String detectProperties) {
phoneHomeRequestBodyBuilder.setThirdPartyVersion(thirdPartyVersion);
phoneHomeRequestBodyBuilder.setPluginVersion(pluginVersion);

phoneHomeDataService.phoneHome(phoneHomeRequestBodyBuilder);
phoneHomeTask = phoneHomeDataService.startPhoneHome(phoneHomeRequestBodyBuilder);
}
} catch (final Exception e) {
logger.debug("Phone Home failed : " + e.getMessage(), e);
Expand All @@ -167,6 +170,9 @@ public void runCommonDetectStep(final String detectProperties) {
logger.error(e.getMessage(), e);
run.setResult(Result.UNSTABLE);
}
if (phoneHomeDataService != null && phoneHomeTask != null) {
phoneHomeDataService.endPhoneHome(phoneHomeTask);
}
}

public List<String> getCorrectedParameters(final String commandLineParameters) throws DetectJenkinsException {
Expand Down

0 comments on commit 0c0f06c

Please sign in to comment.