jenkins.model.Jenkins.getCloud()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(641)

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

Jenkins.getCloud介绍

[英]Gets a Cloud by Cloud#name, or null.
[中]按云#名称或null获取云。

代码示例

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

public MesosCloud getCloud() {
 if (cloud == null) {
  cloud = (MesosCloud) getJenkins().getCloud(cloudName);
 }
 return cloud;
}

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

public DockerCloud getCloud() {
  if (cloudId == null) return null;
  final Cloud cloud = Jenkins.getInstance().getCloud(cloudId);
  if (cloud == null) {
    throw new RuntimeException("Failed to retrieve Cloud " + cloudId);
  }
  if (!(cloud instanceof DockerCloud)) {
    throw new RuntimeException(cloudId + " is not a DockerCloud, it's a " + cloud.getClass().toString());
  }
  return (DockerCloud) cloud;
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

public static DockerCloud getCloudByName(String name) {
  final Cloud cloud = Jenkins.getInstance().getCloud(name);
  if (cloud instanceof DockerCloud) {
    return (DockerCloud) cloud;
  }
  if (isNull(cloud)) {
    throw new RuntimeException("Cloud " + name + "not found");
  }
  return null;
}

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

public static KubernetesCloud getKubernetesCloud(String kubeName) {
  final Jenkins instance = Jenkins.getInstance();
  if (instance == null) {
    return null;
  }
  final Cloud cloud = instance.getCloud(kubeName);
  return (cloud != null && cloud instanceof KubernetesCloud) ? (KubernetesCloud)cloud : null;
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

@CheckForNull
public AzureVMCloud getCloud() {
  return (AzureVMCloud) Jenkins.getInstance().getCloud(cloudName);
}

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

public static DockerCloud getCloudByName(String name) {
  return (DockerCloud) Jenkins.getInstance().getCloud(name);
}

代码示例来源:origin: awslabs/ec2-spot-jenkins-plugin

public EC2FleetCloud getCloud() {
  return (EC2FleetCloud) Jenkins.getInstance().getCloud(cloudName);
}

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

public EC2Cloud getCloud() {
  return (EC2Cloud) Jenkins.getInstance().getCloud(cloudName);
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

@Nonnull
public DockerCloud getCloud() {
  final Cloud cloud = Jenkins.getInstance().getCloud(getCloudId());
  if (cloud == null) {
    throw new RuntimeException("Docker template " + dockerSlaveTemplate + " has no assigned Cloud.");
  }
  if (!cloud.getClass().isAssignableFrom(DockerCloud.class)) {
    throw new RuntimeException("Assigned cloud is not DockerCloud");
  }
  return (DockerCloud) cloud;
}

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

protected @Nonnull DockerCloud getCloud(Run<?, ?> build, Launcher launcher) {
  // Did we specify?
  if (!Strings.isNullOrEmpty(cloudName)) {
    DockerCloud specifiedCloud = (DockerCloud)Jenkins.getInstance().getCloud(cloudName);
    if( specifiedCloud == null )
      throw new IllegalStateException("Could not find a cloud named " + cloudName);
    return specifiedCloud;
  }
  // Otherwise default to where we ran
  Optional<DockerCloud> cloud = JenkinsUtils.getCloudThatWeBuiltOn(build, launcher);
  if (!cloud.isPresent()) {
    throw new IllegalStateException("Cannot list cloud for docker action");
  }
  return cloud.get();
}

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

/**
 * Returns the cloud instance which created this agent.
 * @return the cloud instance which created this agent.
 * @throws IllegalStateException if the cloud doesn't exist anymore, or is not a {@link KubernetesCloud}.
 */
@Nonnull
public KubernetesCloud getKubernetesCloud() {
  Cloud cloud = Jenkins.getInstance().getCloud(getCloudName());
  if (cloud instanceof KubernetesCloud) {
    return (KubernetesCloud) cloud;
  } else {
    throw new IllegalStateException(getClass().getName() + " can be launched only by instances of " + KubernetesCloud.class.getName());
  }
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

@CheckForNull
@Override
public DockerClient getClient() {
  final Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
  if (cloud instanceof DockerCloud) {
    final DockerCloud dockerCloud = (DockerCloud) cloud;
    return dockerCloud.getClient();
  }
  return null;
}

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

@Override
  public Cloud newInstance(StaplerRequest req, JSONObject formData) throws Descriptor.FormException {
    if (req != null) {
      // We prevent the cloud reconfiguration from the web UI
      String cloudName = req.getParameter("cloudName");
      return Jenkins.getInstance().getCloud(cloudName);
    } else {
      throw new IllegalStateException("Expecting req to be non-null");
    }
  }
}

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

/**
 * @deprecated Please use the strongly typed getKubernetesCloud() instead.
 */
@Deprecated
public Cloud getCloud() {
  return Jenkins.getInstance().getCloud(getCloudName());
}

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

/**
 * Re-inject the dynamic template when resuming the pipeline
 */
@Override
public void onResume() {
  super.onResume();
  Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
  if (cloud == null) {
    throw new RuntimeException(String.format("Cloud does not exist: %s", cloudName));
  }
  if (!(cloud instanceof KubernetesCloud)) {
    throw new RuntimeException(String.format("Cloud is not a Kubernetes cloud: %s (%s)", cloudName,
        cloud.getClass().getName()));
  }
  KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud;
  kubernetesCloud.addDynamicTemplate(newTemplate);
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

public static AzureVMCloud getCloud(String cloudName) {
  return Jenkins.getInstance() == null ? null : (AzureVMCloud) Jenkins.getInstance().getCloud(cloudName);
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

public AzureVMCloud getCloud(String cloudName) {
  return Jenkins.getInstance() == null ? null : (AzureVMCloud) Jenkins.getInstance().getCloud(cloudName);
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

public FormValidation doCheckCloudName(@QueryParameter String cloudName) {
  try {
    final Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
    if (cloud instanceof DockerCloud) {
      final DockerCloud dockerCloud = (DockerCloud) cloud;
      Version verResult = dockerCloud.getConnector().getClient().versionCmd().exec();
      return ok(reflectionToString(verResult, MULTI_LINE_STYLE));
    } else {
      return FormValidation.error("cloudId '" + cloudName + "' isn't DockerCloud");
    }
  } catch (Throwable t) {
    return error(t, "error");
  }
}

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

@Override
public KubernetesClient load(String kubeName) throws Exception {
  final Jenkins instance = Jenkins.getInstance();
  final Cloud cloud = (instance != null) ? instance.getCloud(kubeName) : null;
  if (cloud != null && cloud instanceof KubernetesCloud) {
    KubernetesCloud kubeCloud = (KubernetesCloud) cloud;
    return createKubernetesClient(kubeCloud.getKubernetesCloudParams() );
  }
  String msg = "There is no KubernetesCloud with name: " + kubeName;
  LOGGER.severe(msg);
  throw new RepositoryException(msg);
}

代码示例来源:origin: io.fabric8.pipeline/kubernetes-pipeline-arquillian-steps

/**
 * Obtains a {@link KubernetesClient} either from the configured {@link Cloud} or a default instance.
 * @return
 * @throws AbortException
 */
protected KubernetesClient getKubernetesClient() throws AbortException {
  Cloud cloud = Jenkins.getInstance().getCloud(getStep().getCloud());
  if (cloud == null) {
    LOGGER.warning("Cloud does not exist: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
  } else if (!(cloud instanceof KubernetesCloud)) {
    LOGGER.warning("Cloud is not a Kubernetes cloud: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
  } else {
    KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud;
    try {
      String json = Serialization.asJson(kubernetesCloud.connect().getConfiguration());
      return DefaultKubernetesClient.fromConfig(json);
    } catch (Throwable t) {
      LOGGER.warning("Could not connect to cloud: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
    }
  }
  return new DefaultKubernetesClient();
}

相关文章

Jenkins类方法