hudson.model.JDK类的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中hudson.model.JDK类的一些代码示例,展示了JDK类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JDK类的具体详情如下:
包路径:hudson.model.JDK
类名称:JDK

JDK介绍

[英]Information about JDK installation.
[中]关于JDK安装的信息。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
public EnvVars getEnvironment(Node node, TaskListener listener) throws IOException, InterruptedException {
  EnvVars env =  super.getEnvironment(node, listener);
  JDK jdkTool = getJDK();
  if (jdkTool != null) {
    if (node != null) { // just in case were not in a build
      jdkTool = jdkTool.forNode(node, listener);
    }
    jdkTool.buildEnvVars(env);
  } else if (!JDK.isDefaultName(jdk)) {
    listener.getLogger().println("No JDK named ‘" + jdk + "’ found");
  }
  return env;
}

代码示例来源:origin: jenkinsci/jenkins

public JDK forEnvironment(EnvVars environment) {
  return new JDK(getName(), environment.expand(getHome()));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns true if the executable exists.
 */
public boolean getExists() {
  return getExecutable().exists();
}

代码示例来源:origin: jenkinsci/jenkins

public JDK forNode(Node node, TaskListener log) throws IOException, InterruptedException {
  return new JDK(getName(), translateFor(node, log));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * install directory.
 *
 * @deprecated as of 1.304
 *      Use {@link #getHome()}
 */
@Deprecated
public String getJavaHome() {
  return getHome();
}

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

@Override
 protected void buildEnvVars(EnvVars env, MavenInstallation mi) throws IOException, InterruptedException {
  super.buildEnvVars(env, mi);
  // Override JDK in case it is set on Sonar publisher
  if (jdk != null) {
   Computer computer = Computer.currentComputer();
   if (computer != null) {
    // just in case were not in a build
    jdk = jdk.forNode(computer.getNode(), listener);
   }
   jdk.buildEnvVars(env);
  }
 }
}

代码示例来源:origin: jenkinsci/fitnesse-plugin

jdk = jdk.forNode(node, listener);
java = getJavaBinFromjavaHome(workingDirectory, jdk.getHome());

代码示例来源:origin: jenkinsci/jenkins

/**
 * Overwrites the JDK setting.
 */
public void setJDK(JDK jdk) throws IOException {
  this.jdk = jdk.getName();
  save();
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

@Test
  @ConfiguredWithCode("JdkConfiguratorTest.yml")
  public void should_configure_maven_tools_and_global_config() {
    final Object descriptor = j.jenkins.getDescriptorOrDie(JDK.class);
    Assert.assertNotNull(descriptor);
    Assert.assertEquals(1, ((JDK.DescriptorImpl) descriptor).getInstallations().length);

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

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

    JDKInstaller installer = installSourceProperty.installers.get(JDKInstaller.class);
    Assert.assertEquals("jdk-8u181-oth-JPR", installer.id);
    Assert.assertTrue(installer.acceptLicense);
  }
}

代码示例来源:origin: jenkinsci/jenkinsfile-runner

jenkins.getJDKs().add(new JDK("default",System.getProperty("java.home")));

代码示例来源:origin: jenkinsci/pipeline-model-definition-plugin

@Test
  public void buildPluginParentPOM() throws Exception {
    Maven.MavenInstallation maven350 = ToolInstallations.configureMaven35();
    JDK[] jdks = j.jenkins.getDescriptorByType(JDK.DescriptorImpl.class).getInstallations();
    JDK thisJdk = null;
    for (JDK j : jdks) {
      if (j.getName().equals("default")) {
        thisJdk = j;
      }
    }
    assertNotNull("Couldn't find JDK named 'default'", thisJdk);

    expect("buildPluginParentPOM")
        .logContains("[Pipeline] { (build)",
            "BUILD SUCCESS",
            "M2_HOME: " + maven350.getHome(),
            "JAVA_HOME: " + thisJdk.getHome())
        .go();
  }
}

代码示例来源:origin: jenkinsci/pipeline-maven-plugin

/**
 * 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);
}

代码示例来源:origin: org.jvnet.hudson.main/maven-plugin

public JDK getJava(TaskListener log) throws IOException, InterruptedException {
  JDK jdk = mms.getJDK();
  if (jdk != null) jdk = jdk.forNode(getCurrentNode(), log).forEnvironment(envVars);
  return jdk;
}

代码示例来源:origin: jenkinsci/maven-plugin

@Override public JDK call() throws Error {
    JDK jdk = new JDK("this", System.getProperty("java.home"));
    return jdk.getExists() ? jdk : /* i.e. just run "java" and hope for the best */null;
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Sets PATH and JAVA_HOME from this JDK.
 */
@Override
public void buildEnvVars(EnvVars env) {
  buildEnvVars((Map)env);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * If the user chose the default JDK, make sure we got 'java' in PATH.
 */
public FormValidation doDefaultJDKCheck(StaplerRequest request, @QueryParameter String value) {
  if (!value.equals("(Default)")) // assume the user configured named ones properly in system config ---
  // or else system config should have reported form field validation errors.
  {
    return FormValidation.ok();
  }
  // default JDK selected. Does such java really exist?
  if (JDK.isDefaultJDKValid(Hudson.this)) {
    return FormValidation.ok();
  } else {
    return FormValidation.errorWithMarkup(Messages.Hudson_NoJavaInPath(request.getContextPath()));
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * If the user chose the default JDK, make sure we got 'java' in PATH.
 */
public FormValidation doDefaultJDKCheck(StaplerRequest request, @QueryParameter String value) {
  if(!JDK.isDefaultName(value))
    // assume the user configured named ones properly in system config ---
    // or else system config should have reported form field validation errors.
    return FormValidation.ok();
  // default JDK selected. Does such java really exist?
  if(JDK.isDefaultJDKValid(Jenkins.this))
    return FormValidation.ok();
  else
    return FormValidation.errorWithMarkup(Messages.Hudson_NoJavaInPath(request.getContextPath()));
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

public JDK forNode(Node node, TaskListener log) throws IOException, InterruptedException {
  return new JDK(getName(), translateFor(node, log));
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the path to the bin directory.
 */
public File getBinDir() {
  return new File(getHome(),"bin");
}
/**

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

private void computeJdkToUse(Run<?, ?> build, FilePath workspace, TaskListener listener, EnvVars env) throws IOException, InterruptedException {
 JDK jdkToUse = getJdkToUse(getProject(build));
 if (jdkToUse != null) {
  Computer computer = workspace.toComputer();
  // just in case we are not in a build
  if (computer != null) {
   jdkToUse = jdkToUse.forNode(computer.getNode(), listener);
  }
  jdkToUse.buildEnvVars(env);
 }
}

相关文章