All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.extension.jenkins.client.DefaultJenkinsClientFactory.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.extension.jenkins.client

import net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration
import net.nemerosa.ontrack.extension.jenkins.JenkinsConfigurationProperties
import org.springframework.boot.web.client.RestTemplateBuilder
import org.springframework.stereotype.Component
import java.time.Duration

@Component
class DefaultJenkinsClientFactory(
    private val jenkinsConfigurationProperties: JenkinsConfigurationProperties,
) : JenkinsClientFactory {

    override fun getClient(configuration: JenkinsConfiguration): JenkinsClient {
        return DefaultJenkinsClient(
            url = configuration.url,
            client = RestTemplateBuilder()
                .rootUri(configuration.url)
                .basicAuthentication(configuration.user, configuration.password)
                .setReadTimeout(Duration.ofSeconds(jenkinsConfigurationProperties.timeout.toLong()))
                .build()
        )
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy