use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method jenkins_primitive_attributes.
@Test
@ConfiguredWithCode("Primitives.yml")
public void jenkins_primitive_attributes() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
assertEquals(6666, jenkins.getSlaveAgentPort());
assertEquals(false, jenkins.isUsageStatisticsCollected());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class TopLevelItemConfigurator method configure.
@Override
public TopLevelItem configure(Object c) throws Exception {
Map config = (Map) c;
final Jenkins jenkins = Jenkins.getInstance();
final TopLevelItemDescriptor descriptor = (TopLevelItemDescriptor) jenkins.getDescriptorOrDie(target);
final String name = (String) config.remove("name");
final TopLevelItem item = descriptor.newInstance(jenkins, name);
configure(config, item);
return item;
}
use of jenkins.model.Jenkins in project contrast-continuous-application-security-plugin by jenkinsci.
the class VulnerabilityTrendHelper method createSDK.
public static ContrastSDK createSDK(String username, String serviceKey, String apiKey, String teamServerUrl) {
ContrastSDK contrastSDK;
Jenkins jenkinsInstance = Jenkins.getInstance();
ProxyConfiguration proxyConfig = null;
if (jenkinsInstance != null) {
proxyConfig = jenkinsInstance.proxy;
}
URL url = null;
Proxy proxyToUse = Proxy.NO_PROXY;
try {
url = new URL(teamServerUrl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
if (proxyConfig != null && url != null) {
Proxy proxy = proxyConfig.createProxy(url.getHost());
if (proxy != null && proxy.type() == Proxy.Type.HTTP) {
proxyToUse = proxy;
}
}
contrastSDK = new ContrastSDK(username, serviceKey, apiKey, teamServerUrl, proxyToUse);
return contrastSDK;
}
use of jenkins.model.Jenkins in project selenium_java by sergueik.
the class JobHistoryReportImpl method getProjectExecutions.
@Override
public Map<String, List<BuildDetails>> getProjectExecutions(final String jobName, 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, jobName, 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 badge-plugin by jenkinsci.
the class BadgeAction method getIconPath.
public static String getIconPath(String icon) {
if (icon == null)
return null;
if (icon.startsWith("/"))
return icon;
// Try plugin images dir, fallback to Hudson images dir
Jenkins jenkins = Jenkins.getInstance();
PluginWrapper wrapper = jenkins.getPluginManager().getPlugin(BadgePlugin.class);
boolean pluginIconExists = (wrapper != null) && new File(wrapper.baseResourceURL.getPath() + "/images/" + icon).exists();
return pluginIconExists ? "/plugin/" + wrapper.getShortName() + "/images/" + icon : Hudson.RESOURCE_PATH + "/images/16x16/" + icon;
}
Aggregations