Java 类hudson.model.JDK 实例源码

项目:Jenkins-Plugin-Examples    文件:ToolStepTest.java   
@Test public void configRoundTrip() throws Exception {
    String name = "My JDK";
    JDK.DescriptorImpl desc = r.jenkins.getDescriptorByType(JDK.DescriptorImpl.class);
    String type = desc.getId();
    r.jenkins.getJDKs().add(new JDK(name, "/wherever"));
    ToolStep s = new StepConfigTester(r).configRoundTrip(new ToolStep(name));
    assertEquals(name, s.getName());
    assertEquals(null, s.getType());
    s.setType(type);
    s = new StepConfigTester(r).configRoundTrip(s);
    assertEquals(name, s.getName());
    if (SymbolLookup.getSymbolValue(desc).isEmpty()) {
        assertEquals(type, s.getType());
    } // else (Jenkins 2.x) StepConfigTester does not make sense since in real life we would not read an existing value (an ID) into a pulldown listing only symbols
}
项目: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;
}
项目:pipeline-maven-plugin    文件:WithMavenStepExecution.java   
/**
 * 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] use 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 \"docker.image().inside{...}\"," +
                " 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] use JDK installation " + jdkInstallationName);

    JDK jdk = Jenkins.getActiveInstance().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);

}
项目: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);
    }
}
项目: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;
}
项目:apache-httpcomponents-client-4-api-plugin    文件:Client4JDKInstaller.java   
@Override
public boolean isApplicable(Class<? extends ToolInstallation> toolType) {
    return toolType==JDK.class;
}
项目:pipeline-maven-plugin    文件:WithMavenStep.java   
private JDK.DescriptorImpl getJDKDescriptor() {
    return Jenkins.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
}
项目:zaproxy-plugin    文件:ZAProxy.java   
/**
 * Gets the JDK that this Sonar builder is configured with, or null.
 */
public JDK getJDK() {
    return Jenkins.getInstance().getJDK(jdk);
}
项目:cloudtest-plugin    文件:MakeAppTouchTestable.java   
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    ArgumentListBuilder args = new ArgumentListBuilder();
    JDK java = build.getProject().getJDK();
    if (java!=null)
        args.add(java.getHome()+"/bin/java");
    else
        args.add("java");

    CloudTestServer s = getServer();
    if (s==null)
        throw new AbortException("No TouchTest server is configured in the system configuration.");

    EnvVars envs = build.getEnvironment(listener);

    FilePath path = new MakeAppTouchTestableInstaller(s).performInstallation(build.getBuiltOn(), listener);

    args.add(DEFAULT_JAVA_OPTION)
        .add(new QuotedStringTokenizer(envs.expand(javaOptions)).toArray())
        .add("-jar")
        .add(path.child("MakeAppTouchTestable.jar"))
        .add("-overwriteapp")
        .add("-url").add(s.getUrl());

    if(s.getApitoken() != null && !s.getApitoken().isEmpty()) {
        args.add("-apitoken")
            .add(s.getApitoken()); 
    }
    else {
        args.add("-username",s.getUsername()); 

        if (s.getPassword() != null) {
            args.add("-password")
                .addMasked(s.getPassword().getPlainText()); 
        } 
    }       

    args.add(inputType.getInputType(), envs.expand(projectFile));

    if (target!=null && !target.trim().isEmpty())
        args.add("-target", envs.expand(target));
    if (launchURL!=null && !launchURL.trim().isEmpty())
        args.add("-launchURL", envs.expand(launchURL));
    if (!backupModifiedFiles)
        args.add("-nobackup");

    args.add(new QuotedStringTokenizer(envs.expand(additionalOptions)).toArray());

    int r = launcher.launch().cmds(args).pwd(build.getWorkspace()).stdout(listener).join();
    return r==0;
}