类hudson.model.JDK源码实例Demo

下面列出了怎么用hudson.model.JDK的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void configure_jdk_tool() {
    final JDK.DescriptorImpl descriptor = ExtensionList.lookupSingleton(JDK.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);

    JDK jdk = descriptor.getInstallations()[0];
    assertEquals("jdk8", jdk.getName());
    assertEquals("/jdk", jdk.getHome());

    InstallSourceProperty installSourceProperty = jdk.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());

    JDKInstaller installer = installSourceProperty.installers.get(JDKInstaller.class);
    assertEquals("jdk-8u181-oth-JPR", installer.id);
    assertTrue(installer.acceptLicense);
}
 
@Test
public void toolMetadata() throws Exception {
    PipelineMetadataService svc = new PipelineMetadataService();

    List<ExportedToolDescriptor> tools = new ArrayList<>();
    tools.addAll(Arrays.asList(svc.doToolMetadata()));

    assertFalse(tools.isEmpty());

    ExportedToolDescriptor t = null;

    for (ExportedToolDescriptor a : tools) {
        if (a.getType().equals(JDK.DescriptorImpl.class.getName())) {
            t = a;
        }
    }

    assertNotNull(t);

    assertEquals("jdk", t.getSymbol());
}
 
/**
 * Setup the selected JDK. If none is provided nothing is done.
 */
private void setupJDK() throws AbortException, IOException, InterruptedException {
    String jdkInstallationName = step.getJdk();
    if (StringUtils.isEmpty(jdkInstallationName)) {
        console.println("[withMaven] using JDK installation provided by the build agent");
        return;
    }

    if (withContainer) {
        // see #detectWithContainer()
        LOGGER.log(Level.FINE, "Ignoring JDK installation parameter: {0}", jdkInstallationName);
        console.println("WARNING: \"withMaven(){...}\" step running within a container," +
                " tool installations are not available see https://issues.jenkins-ci.org/browse/JENKINS-36159. " +
                "You have specified a JDK installation \"" + jdkInstallationName + "\", which will be ignored.");
        return;
    }

    console.println("[withMaven] using JDK installation " + jdkInstallationName);

    JDK jdk = Jenkins.getInstance().getJDK(jdkInstallationName);
    if (jdk == null) {
        throw new AbortException("Could not find the JDK installation: " + jdkInstallationName + ". Make sure it is configured on the Global Tool Configuration page");
    }
    Node node = getComputer().getNode();
    if (node == null) {
        throw new AbortException("Could not obtain the Node for the computer: " + getComputer().getName());
    }
    jdk = jdk.forNode(node, listener).forEnvironment(env);
    jdk.buildEnvVars(envOverride);

}
 
源代码4 项目: pipeline-maven-plugin   文件: WithMavenStep.java
@Restricted(NoExternalUse.class) // Only for UI calls
public ListBoxModel doFillJdkItems() {
    ListBoxModel r = new ListBoxModel();
    r.add("--- Use system default JDK ---",null);
    for (JDK installation : getJDKDescriptor().getInstallations()) {
        r.add(installation.getName());
    }
    return r;
}
 
源代码5 项目: jenkins-test-harness   文件: JenkinsRule.java
/**
 * Configures a Jenkins instance for test.
 *
 * @param jenkins jenkins instance which has to be configured
 * @throws Exception if unable to configure
 * @since 2.50
 */
public static void _configureJenkinsForTest(Jenkins jenkins) throws Exception {
    jenkins.setNoUsageStatistics(true); // collecting usage stats from tests is pointless.
    jenkins.servletContext.setAttribute("app", jenkins);
    jenkins.servletContext.setAttribute("version", "?");
    WebAppMain.installExpressionFactory(new ServletContextEvent(jenkins.servletContext));

    // set a default JDK to be the one that the harness is using.
    jenkins.getJDKs().add(new JDK("default", System.getProperty("java.home")));
}
 
源代码6 项目: zaproxy-plugin   文件: ZAProxy.java
/**
 * Set the JDK to use to start ZAP.
 * 
 * @param build
 * @param listener the listener to display log during the job execution in jenkins
 * @param env list of environment variables. Used to set the path to the JDK
 * @throws IOException
 * @throws InterruptedException
 */
private void computeJdkToUse(AbstractBuild<?, ?> build,
		BuildListener listener, EnvVars env) throws IOException, InterruptedException {
	JDK jdkToUse = getJdkToUse(build.getProject());
	if (jdkToUse != null) {
		Computer computer = Computer.currentComputer();
		// just in case we are not in a build
		if (computer != null) {
			jdkToUse = jdkToUse.forNode(computer.getNode(), listener);
		}
		jdkToUse.buildEnvVars(env);
	}
}
 
源代码7 项目: zaproxy-plugin   文件: ZAProxy.java
/**
 * @return JDK to be used with this project.
 */
private JDK getJdkToUse(AbstractProject<?, ?> project) {
	JDK jdkToUse = getJDK();
	if (jdkToUse == null) {
		jdkToUse = project.getJDK();
	}
	return jdkToUse;
}
 
源代码8 项目: pipeline-maven-plugin   文件: WithMavenStep.java
private JDK.DescriptorImpl getJDKDescriptor() {
    return Jenkins.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
}
 
源代码9 项目: zaproxy-plugin   文件: ZAProxy.java
/**
 * Gets the JDK that this Sonar builder is configured with, or null.
 */
public JDK getJDK() {
	return Jenkins.getInstance().getJDK(jdk);
}
 
 类所在包
 类方法
 同包方法