uk.co.codera.ci.tooling.jenkins.JenkinsService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codera-ci-tooling-service-jenkins Show documentation
Show all versions of codera-ci-tooling-service-jenkins Show documentation
Provides integration with jenkins such as creating and deleting jobs automatically.
The newest version!
package uk.co.codera.ci.tooling.jenkins;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JenkinsService {
private static final Logger logger = LoggerFactory.getLogger(JenkinsService.class);
private final JenkinsConnectionDetails jenkinsConfiguration;
private final JenkinsCommandLineInterfaceInvoker cliInvoker;
public JenkinsService(JenkinsConnectionDetails jenkinsConfiguration) {
this(jenkinsConfiguration, new JenkinsCommandLineInterfaceInvoker());
}
public JenkinsService(JenkinsConnectionDetails jenkinsConfiguration, JenkinsCommandLineInterfaceInvoker cliInvoker) {
this.jenkinsConfiguration = jenkinsConfiguration;
this.cliInvoker = cliInvoker;
}
public void createJob(String jobName, String jobDefinition) {
logger.info("Create job with definition [{}]", jobDefinition);
execute(CreateJobCommand.aCreateJobCommand().jobName(jobName).jobDefinition(jobDefinition).with(this.jenkinsConfiguration));
}
public void deleteJob(String jobName) {
logger.info("Delete job with name [{}]", jobName);
execute(DeleteJobCommand.aDeleteJobCommand().jobName(jobName).with(this.jenkinsConfiguration));
}
private void execute(JenkinsCommand.Builder, ?> command) {
command.build().execute(this.cliInvoker);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy