Search in sources :

Example 11 with Jenkins

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());
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Example 12 with Jenkins

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;
}
Also used : Jenkins(jenkins.model.Jenkins) TopLevelItem(hudson.model.TopLevelItem) TopLevelItemDescriptor(hudson.model.TopLevelItemDescriptor) Map(java.util.Map)

Example 13 with Jenkins

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;
}
Also used : Jenkins(jenkins.model.Jenkins) ContrastSDK(com.contrastsecurity.sdk.ContrastSDK) Proxy(java.net.Proxy) MalformedURLException(java.net.MalformedURLException) ProxyConfiguration(hudson.ProxyConfiguration) URL(java.net.URL)

Example 14 with Jenkins

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;
}
Also used : Jenkins(jenkins.model.Jenkins) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) HashMap(java.util.HashMap) List(java.util.List) Date(java.util.Date)

Example 15 with Jenkins

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;
}
Also used : Jenkins(jenkins.model.Jenkins) PluginWrapper(hudson.PluginWrapper) File(java.io.File)

Aggregations

Jenkins (jenkins.model.Jenkins)73 Test (org.junit.Test)22 ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)13 IOException (java.io.IOException)10 File (java.io.File)9 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)9 FlowExecution (org.jenkinsci.plugins.workflow.flow.FlowExecution)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Map (java.util.Map)7 Statement (org.junit.runners.model.Statement)7 CheckForNull (javax.annotation.CheckForNull)6 FilePath (hudson.FilePath)5 Computer (hudson.model.Computer)5 URL (java.net.URL)5 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)5 Issue (org.jvnet.hudson.test.Issue)5 Item (hudson.model.Item)4 Node (hudson.model.Node)4 Date (java.util.Date)4