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

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

本文整理了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

  1. public MesosCloud getCloud() {
  2. if (cloud == null) {
  3. cloud = (MesosCloud) getJenkins().getCloud(cloudName);
  4. }
  5. return cloud;
  6. }

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

  1. public DockerCloud getCloud() {
  2. if (cloudId == null) return null;
  3. final Cloud cloud = Jenkins.getInstance().getCloud(cloudId);
  4. if (cloud == null) {
  5. throw new RuntimeException("Failed to retrieve Cloud " + cloudId);
  6. }
  7. if (!(cloud instanceof DockerCloud)) {
  8. throw new RuntimeException(cloudId + " is not a DockerCloud, it's a " + cloud.getClass().toString());
  9. }
  10. return (DockerCloud) cloud;
  11. }

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

  1. public static DockerCloud getCloudByName(String name) {
  2. final Cloud cloud = Jenkins.getInstance().getCloud(name);
  3. if (cloud instanceof DockerCloud) {
  4. return (DockerCloud) cloud;
  5. }
  6. if (isNull(cloud)) {
  7. throw new RuntimeException("Cloud " + name + "not found");
  8. }
  9. return null;
  10. }

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

  1. public static KubernetesCloud getKubernetesCloud(String kubeName) {
  2. final Jenkins instance = Jenkins.getInstance();
  3. if (instance == null) {
  4. return null;
  5. }
  6. final Cloud cloud = instance.getCloud(kubeName);
  7. return (cloud != null && cloud instanceof KubernetesCloud) ? (KubernetesCloud)cloud : null;
  8. }

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

  1. @CheckForNull
  2. public AzureVMCloud getCloud() {
  3. return (AzureVMCloud) Jenkins.getInstance().getCloud(cloudName);
  4. }

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

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

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

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

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

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

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

  1. @Nonnull
  2. public DockerCloud getCloud() {
  3. final Cloud cloud = Jenkins.getInstance().getCloud(getCloudId());
  4. if (cloud == null) {
  5. throw new RuntimeException("Docker template " + dockerSlaveTemplate + " has no assigned Cloud.");
  6. }
  7. if (!cloud.getClass().isAssignableFrom(DockerCloud.class)) {
  8. throw new RuntimeException("Assigned cloud is not DockerCloud");
  9. }
  10. return (DockerCloud) cloud;
  11. }

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

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

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

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

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

  1. @CheckForNull
  2. @Override
  3. public DockerClient getClient() {
  4. final Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
  5. if (cloud instanceof DockerCloud) {
  6. final DockerCloud dockerCloud = (DockerCloud) cloud;
  7. return dockerCloud.getClient();
  8. }
  9. return null;
  10. }

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

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

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

  1. /**
  2. * @deprecated Please use the strongly typed getKubernetesCloud() instead.
  3. */
  4. @Deprecated
  5. public Cloud getCloud() {
  6. return Jenkins.getInstance().getCloud(getCloudName());
  7. }

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

  1. /**
  2. * Re-inject the dynamic template when resuming the pipeline
  3. */
  4. @Override
  5. public void onResume() {
  6. super.onResume();
  7. Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
  8. if (cloud == null) {
  9. throw new RuntimeException(String.format("Cloud does not exist: %s", cloudName));
  10. }
  11. if (!(cloud instanceof KubernetesCloud)) {
  12. throw new RuntimeException(String.format("Cloud is not a Kubernetes cloud: %s (%s)", cloudName,
  13. cloud.getClass().getName()));
  14. }
  15. KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud;
  16. kubernetesCloud.addDynamicTemplate(newTemplate);
  17. }

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

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

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

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

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

  1. public FormValidation doCheckCloudName(@QueryParameter String cloudName) {
  2. try {
  3. final Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
  4. if (cloud instanceof DockerCloud) {
  5. final DockerCloud dockerCloud = (DockerCloud) cloud;
  6. Version verResult = dockerCloud.getConnector().getClient().versionCmd().exec();
  7. return ok(reflectionToString(verResult, MULTI_LINE_STYLE));
  8. } else {
  9. return FormValidation.error("cloudId '" + cloudName + "' isn't DockerCloud");
  10. }
  11. } catch (Throwable t) {
  12. return error(t, "error");
  13. }
  14. }

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

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

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

  1. /**
  2. * Obtains a {@link KubernetesClient} either from the configured {@link Cloud} or a default instance.
  3. * @return
  4. * @throws AbortException
  5. */
  6. protected KubernetesClient getKubernetesClient() throws AbortException {
  7. Cloud cloud = Jenkins.getInstance().getCloud(getStep().getCloud());
  8. if (cloud == null) {
  9. LOGGER.warning("Cloud does not exist: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
  10. } else if (!(cloud instanceof KubernetesCloud)) {
  11. LOGGER.warning("Cloud is not a Kubernetes cloud: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
  12. } else {
  13. KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud;
  14. try {
  15. String json = Serialization.asJson(kubernetesCloud.connect().getConfiguration());
  16. return DefaultKubernetesClient.fromConfig(json);
  17. } catch (Throwable t) {
  18. LOGGER.warning("Could not connect to cloud: [" + getStep().getCloud() + "]. Falling back to default KubernetesClient.");
  19. }
  20. }
  21. return new DefaultKubernetesClient();
  22. }

相关文章

Jenkins类方法