use of com.atlassian.jira.rest.client.api.JiraRestClientFactory in project syndesis-qe by syndesisio.
the class IssueHooksUtils method getJiraClient.
private static JiraRestClient getJiraClient(Scenario scenario) {
String userName = "";
String password = "";
String instanceUrl = "";
URI uri = null;
Optional<Account> account = AccountsDirectory.getInstance().getAccount(Account.Name.JIRA_HOOK);
if (account.isPresent()) {
if (!account.get().getProperties().keySet().containsAll(Arrays.asList("username", "password", "instanceUrl"))) {
logError(scenario, "Account with name \"Jira\" and properties \"username\", \"password\", \"instanceUrl\" is required in credentials.json file.");
logError(scenario, "If you want to get known issues from Jira in logs in case of scenario fails, update your credentials.");
return null;
} else {
userName = account.get().getProperty("username");
password = account.get().getProperty("password");
instanceUrl = account.get().getProperty("instanceUrl");
}
}
JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
try {
uri = new URI(instanceUrl);
} catch (URISyntaxException e) {
log.error("URL {} is a malformed URL", instanceUrl);
e.printStackTrace();
}
return factory.createWithBasicHttpAuthentication(uri, userName, password);
}
Aggregations