use of jenkins.model.Jenkins in project selenium_java by sergueik.
the class JobsByDateReportImpl method getProjectExecutions.
@Override
public Map<String, List<BuildDetails>> getProjectExecutions(final String startDateString, final String endDateString) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
// unit tests won't have a Jenkins instance
jenkins.checkPermission(DbAuditPlugin.RUN);
}
final Map<String, List<BuildDetails>> retval = new HashMap<String, List<BuildDetails>>();
final Date startDate = DbAuditReportUtils.stringToDate(startDateString);
final Date endDate = DbAuditReportUtils.stringToDate(endDateString);
final String jenkinsHost = getJenkinsHostname();
final List<String> projectNames = getRepository().getProjectNames(jenkinsHost, startDate, endDate);
for (final String projectName : projectNames) {
final List<BuildDetails> buildDetails = getRepository().getBuildDetails(jenkinsHost, projectName, startDate, endDate);
if (!buildDetails.isEmpty()) {
retval.put(projectName, buildDetails);
}
}
return retval;
}
use of jenkins.model.Jenkins in project selenium_java by sergueik.
the class JobsByParamReportImpl method getProjectExecutions.
/**
* @see org.jenkins.plugins.audit2db.reports.JobsByParamReport#getProjectExecutions(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public Map<String, List<BuildDetails>> getProjectExecutions(final String paramName, final String paramValue, final String startDateString, final String endDateString) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
// unit tests won't have a Jenkins instance
jenkins.checkPermission(DbAuditPlugin.RUN);
}
final Map<String, List<BuildDetails>> retval = new HashMap<String, List<BuildDetails>>();
final Date startDate = DbAuditReportUtils.stringToDate(startDateString);
final Date endDate = DbAuditReportUtils.stringToDate(endDateString);
final String jenkinsHost = getJenkinsHostname();
final List<BuildDetails> buildDetails = getRepository().getBuildDetailsByParams(jenkinsHost, paramName, paramValue, startDate, endDate);
for (final BuildDetails details : buildDetails) {
final String projectName = details.getName();
if (!retval.containsKey(projectName)) {
retval.put(projectName, new ArrayList<BuildDetails>());
}
retval.get(projectName).add(details);
}
return retval;
}
use of jenkins.model.Jenkins in project selenium_java by sergueik.
the class BuildDetailsResolver method addBuildNodeFromContext.
private static void addBuildNodeFromContext(BuildDetailsImpl details, Run<?, ?> run, Computer computer) throws IOException, InterruptedException {
LOGGER.finer("resolving build node");
Jenkins jenkins = Jenkins.getInstance();
LOGGER.finer("jenkins: " + jenkins);
LOGGER.finer("computer: " + computer);
Node node = computer.getNode();
LOGGER.finer("node: " + node);
String rootUrl = jenkins != null ? jenkins.getRootUrl() : "http://unconfigured-jenkins-server/";
LOGGER.finer("rootUrl: " + rootUrl);
URL url = new URL(rootUrl);
String masterHostname = url.getHost();
String urlString = String.format("%s/%s", rootUrl, computer.getUrl()).replaceAll("(\\w)(\\/{2,})(\\w)", "$1/$3");
BuildNode buildNode = new BuildNodeImpl(resolveMasterIpAddress(computer), masterHostname, computer.getDisplayName(), // url
urlString, node.getNodeName(), node.getNodeDescription(), node.getLabelString());
LOGGER.finer("buildNode: " + buildNode);
details.setNode(buildNode);
}
use of jenkins.model.Jenkins in project sonar-scanner-jenkins by SonarSource.
the class SonarGlobalConfiguration method migrate.
/**
* Attempts to migrated data from SonarPublished, which was previously holding the global configuration.
* It is thread safe and will refuse to migrate if a SonarQube installation already exists in this class.
* Migration will only be attempted once.
*/
@Initializer(after = InitMilestone.PLUGINS_PREPARED)
public void migrate() {
if (migrated) {
return;
}
synchronized (this) {
if (migrated) {
return;
}
// SonarPublisher might be null if Maven plugin is disabled or not installed
Jenkins j = Jenkins.getInstance();
DescriptorImpl publisher = j.getDescriptorByType(SonarPublisher.DescriptorImpl.class);
if (publisher != null && publisher.getDeprecatedInstallations() != null && publisher.getDeprecatedInstallations().length > 0) {
if (ArrayUtils.isEmpty(this.installations)) {
this.installations = publisher.getDeprecatedInstallations();
this.buildWrapperEnabled = publisher.isDeprecatedBuildWrapperEnabled();
save();
} else {
Logger.LOG.warning("SonarQube server configurations exist in both deprecated SonarPublisher and SonarGlobalConfiguration. Deleting deprecated configuration..");
}
publisher.deleteGlobalConfiguration();
}
migrated = true;
}
}
use of jenkins.model.Jenkins in project sonar-scanner-jenkins by SonarSource.
the class SonarInstallation method all.
/**
* @return all available installations, never <tt>null</tt> but can be empty.
* @since 1.7
*/
public static final SonarInstallation[] all() {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
// for unit test
return new SonarInstallation[0];
}
SonarGlobalConfiguration sonarDescriptor = jenkins.getDescriptorByType(SonarGlobalConfiguration.class);
return sonarDescriptor.getInstallations();
}
Aggregations