Search in sources :

Example 1 with OntrackGitLabClient

use of net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient in project ontrack by nemerosa.

the class GitLabConfigurationServiceImpl method validate.

@Override
protected ConnectionResult validate(GitLabConfiguration configuration) {
    try {
        // Gets the client
        OntrackGitLabClient client = gitLabClientFactory.create(configuration);
        // Gets the list of repositories
        client.getRepositories();
        // OK
        return ConnectionResult.ok();
    } catch (Exception ex) {
        applicationLogService.log(ApplicationLogEntry.error(ex, NameDescription.nd("gitlab", "GitLab connection issue"), configuration.getUrl()).withDetail("gitlab-config-name", configuration.getName()).withDetail("gitlab-config-url", configuration.getUrl()));
        return ConnectionResult.error(ex.getMessage());
    }
}
Also used : OntrackGitLabClient(net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient)

Example 2 with OntrackGitLabClient

use of net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient in project ontrack by nemerosa.

the class GitLabIssueServiceExtension method getIssue.

@Override
public Issue getIssue(IssueServiceConfiguration issueServiceConfiguration, String issueKey) {
    GitLabIssueServiceConfiguration configuration = (GitLabIssueServiceConfiguration) issueServiceConfiguration;
    OntrackGitLabClient client = gitLabClientFactory.create(configuration.getConfiguration());
    return client.getIssue(configuration.getRepository(), getIssueId(issueKey));
}
Also used : OntrackGitLabClient(net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient) GitLabIssueServiceConfiguration(net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration)

Example 3 with OntrackGitLabClient

use of net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient in project ontrack by nemerosa.

the class GitLabIssueServiceExtensionTest method get_issue_test.

protected Issue get_issue_test(String token, int id) {
    OntrackGitLabClient client = mock(OntrackGitLabClient.class);
    when(client.getIssue(configuration.getRepository(), id)).thenReturn(issueWrapper);
    when(gitHubClientFactory.create(configuration.getConfiguration())).thenReturn(client);
    return extension.getIssue(configuration, token);
}
Also used : OntrackGitLabClient(net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient)

Example 4 with OntrackGitLabClient

use of net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient in project ontrack by nemerosa.

the class GitLabHealthIndicator method getHealth.

@Override
protected Health getHealth(GitLabConfiguration config) {
    try {
        // Gets the client
        OntrackGitLabClient client = gitLabClientFactory.create(config);
        // Gets the list of repositories
        client.getRepositories();
        // OK
        return Health.up().build();
    } catch (Exception ex) {
        return Health.down(ex).build();
    }
}
Also used : OntrackGitLabClient(net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient)

Aggregations

OntrackGitLabClient (net.nemerosa.ontrack.extension.gitlab.client.OntrackGitLabClient)4 GitLabIssueServiceConfiguration (net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration)1