當前位置: 首頁>>代碼示例>>Java>>正文


Java Hudson類代碼示例

本文整理匯總了Java中hudson.model.Hudson的典型用法代碼示例。如果您正苦於以下問題:Java Hudson類的具體用法?Java Hudson怎麽用?Java Hudson使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Hudson類屬於hudson.model包,在下文中一共展示了Hudson類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doParamsSubmit

import hudson.model.Hudson; //導入依賴的package包/類
public void doParamsSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
    List<BuildTargetParameter> buildTargetParams;
    TargetParameterBuildAction paramAction;
    JSONObject jsonObject;
    TargetBuildParameterUtil buildParamUtil = new TargetBuildParameterUtil();
    jsonObject = req.getSubmittedForm();
    buildTargetParams = buildParamUtil.parse(jsonObject);
    if (buildTargetParams == null) {
        rsp.sendRedirect(400, "Invalid Parameters - All Fields must be filed");
        return;
    } else {
        paramAction = new TargetParameterBuildAction();
        paramAction.setBaseBranch(jsonObject.getString("baseBranch"));
        paramAction.setParameters(buildTargetParams);
        Hudson.getInstance().getQueue().schedule2(project, 0, paramAction, new CauseAction(new Cause.UserIdCause()));
    }
    rsp.sendRedirect("../");
}
 
開發者ID:maidsafe-archive,項目名稱:CI-Jenkins-Plugin,代碼行數:19,代碼來源:GitHubTargetParameterAction.java

示例2: newInstance

import hudson.model.Hudson; //導入依賴的package包/類
@Override
public Node newInstance(StaplerRequest req, JSONObject formData) throws FormException {
    EC2OndemandSlave ec2AbstractSlave = (EC2OndemandSlave) super.newInstance(req, formData);

    if (!ec2AbstractSlave.isAlive(true)) {
        LOGGER.info("EC2 instance terminated externally: " + ec2AbstractSlave.getInstanceId());
        try {
            Hudson.getInstance().removeNode(ec2AbstractSlave);
        } catch (IOException ioe) {
            LOGGER.log(Level.WARNING, "Attempt to reconfigure EC2 instance which has been externally terminated: " + ec2AbstractSlave.getInstanceId(), ioe);
        }

        return null;
    }

    return ec2AbstractSlave;
}
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:18,代碼來源:EC2OndemandSlave.java

示例3: execute

import hudson.model.Hudson; //導入依賴的package包/類
@Override
protected void execute(TaskListener listener) throws IOException, InterruptedException {
    for (Node node : Hudson.getInstance().getNodes()) {
        if (node instanceof EC2AbstractSlave) {
            final EC2AbstractSlave ec2Slave = (EC2AbstractSlave) node;
            try {
                if (!ec2Slave.isAlive(true)) {
                    LOGGER.info("EC2 instance is dead: " + ec2Slave.getInstanceId());
                    ec2Slave.terminate();
                }
            } catch (AmazonClientException e) {
                LOGGER.info("EC2 instance is dead and failed to terminate: " + ec2Slave.getInstanceId());
                removeNode(ec2Slave);
            }
        }
    }
}
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:18,代碼來源:EC2SlaveMonitor.java

示例4: doProvision

import hudson.model.Hudson; //導入依賴的package包/類
public HttpResponse doProvision(@QueryParameter String template) throws ServletException, IOException {
    checkPermission(PROVISION);
    if (template == null) {
        throw HttpResponses.error(SC_BAD_REQUEST, "The 'template' query parameter is missing");
    }
    SlaveTemplate t = getTemplate(template);
    if (t == null) {
        throw HttpResponses.error(SC_BAD_REQUEST, "No such template: " + template);
    }

    StringWriter sw = new StringWriter();
    StreamTaskListener listener = new StreamTaskListener(sw);
    try {
        EC2AbstractSlave node = t.provision(listener);
        Hudson.getInstance().addNode(node);

        return HttpResponses.redirectViaContextPath("/computer/" + node.getNodeName());
    } catch (AmazonClientException e) {
        throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR, e);
    }
}
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:22,代碼來源:EC2Cloud.java

示例5: doRun

import hudson.model.Hudson; //導入依賴的package包/類
@Override
protected void doRun() {
       ZFSFileSystem fs=null;
       try {
           if(isInsideEC2())
               fs = new LibZFS().getFileSystemByMountPoint(Hudson.getInstance().getRootDir());
       } catch (LinkageError e) {
           // probably not running on OpenSolaris
       }
       if(fs==null) {
           cancel();
           return;
       }
       ZFSPool pool = fs.getPool();
       long a = pool.getAvailableSize();
       long t = pool.getSize();

       // if the disk is 90% filled up and the available space is less than 1GB,
       // notify the user
       ZPoolExpandNotice zen = AdministrativeMonitor.all().get(ZPoolExpandNotice.class);
       zen.activated = t/a>10 && a<1000L*1000*1000;
   }
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:23,代碼來源:ZPoolMonitor.java

示例6: doCheckCloudName

import hudson.model.Hudson; //導入依賴的package包/類
public FormValidation doCheckCloudName(@QueryParameter String value) {
    try {
        Hudson.checkGoodName(value);
    } catch (Failure e){
        return FormValidation.error(e.getMessage());
    }

    String cloudId = createCloudId(value);
    int found = 0;
    for (Cloud c : Hudson.getInstance().clouds) {
        if (c.name.equals(cloudId)) {
            found++;
        }
    }
    if (found>1) {
        return FormValidation.error(Messages.AmazonEC2Cloud_NonUniqName());
    }
    return FormValidation.ok();
}
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:20,代碼來源:AmazonEC2Cloud.java

示例7: isOneClickDeployValid

import hudson.model.Hudson; //導入依賴的package包/類
/**
 * Returns {@code true} if and only if a one click deployment is valid. In other words
 * {@link #isOneClickDeployPossible()} says there are artifacts for deployment. {@link #isOneClickDeployValid()}
 * says the configured one click deploy is fully defined and {@link #isOneClickDeploy()} says that the user
 * has enabled one click deploy for the project.
 *
 * @return {@code true} if and only if a one click deployment is valid.
 */
@SuppressWarnings("unused") // used by stapler
@Exported(name = "oneClickDeployValid", visibility = 2)
public boolean isOneClickDeployValid() {
    if (owner != null && owner.hasPermission(DEPLOY)) {
        DeployNowJobProperty property = owner.getProperty(DeployNowJobProperty.class);
        if (property != null) {
            if (property.isOneClickDeploy()) {
                if (owner.hasPermission(OWN_AUTH) && DeployHost.isValid(property.getHosts(), owner,
                        Hudson.getAuthentication())) {
                    return true;
                }
                if (owner.hasPermission(JOB_AUTH) && DeployHost.isValid(property.getHosts(), owner,
                        ACL.SYSTEM)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:jenkinsci,項目名稱:deployer-framework-plugin,代碼行數:29,代碼來源:DeployNowProjectAction.java

示例8: getDeploySourceDescriptors

import hudson.model.Hudson; //導入依賴的package包/類
/**
 * Returns the {@link DeploySourceDescriptor}s that are valid for the specific context.
 *
 * @param origins the valid origins.
 * @param jobType the project type.
 * @return the {@link DeploySourceDescriptor}s that are valid for the specific context.
 */
@SuppressWarnings("unused") // used by stapler
@NonNull
public List<DeploySourceDescriptor> getDeploySourceDescriptors(@CheckForNull Set<DeploySourceOrigin> origins,
                                                               @CheckForNull Class<? extends AbstractProject>
                                                                       jobType) {
    List<DeploySourceDescriptor> result = new ArrayList<DeploySourceDescriptor>();
    if (origins != null) {
        for (Descriptor<DeploySource> d : Hudson.getInstance().getDescriptorList(DeploySource.class)) {
            if (d instanceof DeploySourceDescriptor) {
                DeploySourceDescriptor descriptor = (DeploySourceDescriptor) d;
                for (DeploySourceOrigin source : origins) {
                    if (descriptor.isSupported(source) && descriptor.isApplicable(jobType)) {
                        if ((isFileTarget() && descriptor.isFileSource())
                                || (isDirectoryTarget() && descriptor.isDirectorySource())) {
                            result.add(descriptor);
                        }
                        break;
                    }
                }
            }
        }
    }
    return result;
}
 
開發者ID:jenkinsci,項目名稱:deployer-framework-plugin,代碼行數:32,代碼來源:DeployTargetDescriptor.java

示例9: isOneClickDeployValid

import hudson.model.Hudson; //導入依賴的package包/類
@Exported(name = "oneClickDeployValid", visibility = 2)
public boolean isOneClickDeployValid() {
    if (owner != null && owner.getParent().hasPermission(DEPLOY)) {
        DeployNowJobProperty property = owner.getParent().getProperty(DeployNowJobProperty.class);
        if (property != null) {
            if (property.isOneClickDeploy()) {
                List<? extends DeployHost<?, ?>> sets = property.getHosts();
                if (owner.getParent().hasPermission(OWN_AUTH) && DeployHost
                        .isValid(sets, owner, Hudson.getAuthentication())) {
                    return true;
                }
                if (owner.getParent().hasPermission(JOB_AUTH) && DeployHost.isValid(sets, owner, ACL.SYSTEM)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:jenkinsci,項目名稱:deployer-framework-plugin,代碼行數:20,代碼來源:DeployNowRunAction.java

示例10: setup

import hudson.model.Hudson; //導入依賴的package包/類
@Before
public void setup() throws Exception {
	DeployApplicationDescriptor descriptor = (DeployApplicationDescriptor)Hudson.getInstance().getDescriptor(DeployApplication.class);
	
	// openshift credentials
	String brokerAddress = TestUtils.getProp("openshift.brokerAddress");
	String username = TestUtils.getProp("openshift.username");
	String password = TestUtils.getProp("openshift.password");
	
	// set openshift server
	Server server = new Server(SERVER_NAME, brokerAddress, username, password);
	descriptor.getServers().add(server);

	// set ssh keys
	String privateKey = ClassLoader.getSystemResource(SSH_PRIVATE_KEY).getFile();
	Field sshPrivateKeyField = DeployApplication.DeployApplicationDescriptor.class.getField("publicKeyPath");
	ReflectionUtils.setField(sshPrivateKeyField, descriptor, privateKey);

	// upload ssh keys
	client = new OpenShiftV2Client(brokerAddress, username, password);
	String publicKey = ClassLoader.getSystemResource(SSH_PUBLIC_KEY).getFile();
	File publicKeyFile = new File(publicKey);
	if (!client.sshKeyExists(publicKeyFile)) {
		client.uploadSSHKey(publicKeyFile);
	}
}
 
開發者ID:jenkinsci,項目名稱:openshift-deployer-plugin,代碼行數:27,代碼來源:BaseJenkinsTest.java

示例11: doCheckHome

import hudson.model.Hudson; //導入依賴的package包/類
@Override
public FormValidation doCheckHome(@QueryParameter File value)
{
    if (!Hudson.getInstance().hasPermission(Hudson.ADMINISTER))
        return FormValidation.ok();

    if (value.getPath().equals(""))
        return FormValidation.ok(); // can be blank for master configurations and overriden on nodes

    if (!value.isDirectory())
        return FormValidation.error("Path to 'fauxpas' must be the directory that contains the 'fauxpas' command. If this is your master and you will be overriding this value on a node you can leave this value blank.");

    File commandFile = new File(value, "fauxpas");
    if(!commandFile.exists())
        return FormValidation.warning( "Unable to locate 'fauxpas' in the provided home directory." );

    return FormValidation.ok();
}
 
開發者ID:FauxPasApp,項目名稱:fauxpas-jenkins-plugin,代碼行數:19,代碼來源:FauxPasAppToolInstallation.java

示例12: doUpdateCache

import hudson.model.Hudson; //導入依賴的package包/類
/**
 * Method which is exposed to trigger the update of the local cache.
 *
 * @param req Request from Jenkins.
 * @param rsp Response for Jenkins.
 * @throws IOException When files operations failed.
 */
public void doUpdateCache(StaplerRequest req, StaplerResponse rsp) throws IOException {
    try {
        DescriptorImpl descriptor = (DescriptorImpl)Hudson.getInstance().getDescriptor(
            DynamicConfigurationDefinition.class);
        ccrUrl = descriptor.getCcrUrl();
        localCachePath = descriptor.getLocalCachePath();

        downloadAllAndSaveToCache();

        LOG.info(Messages.CCRParameterCacheManager_UpdateSuccessful());
        rsp.getWriter().write(Messages.CCRParameterCacheManager_UpdateSuccessful());
        rsp.setStatus(200);
    } catch (Exception e) {
        LOG.throwing(this.getClass().getName(), "doCheckForUpdates", e);
        rsp.getWriter().write(Messages.CCRParameterCacheManager_UpdateFailed() + " " + e.getMessage());
        rsp.setStatus(500);
    }
}
 
開發者ID:ederst,項目名稱:ccr-parameter-plugin,代碼行數:26,代碼來源:CacheManager.java

示例13: doSearchSubmit

import hudson.model.Hudson; //導入依賴的package包/類
public void doSearchSubmit(StaplerRequest req, StaplerResponse rsp) 
       throws IOException, UnsupportedEncodingException, ServletException, 
       Descriptor.FormException {
   Hudson.getInstance().checkPermission(View.READ);
   SearchAction action = SearchAction.fromRequest(req);
   
   switch (action) {
       case runSearchButton:
           JobsFilter filter = new JobsFilter(req, this);
           updateSearchCache(filter);
           rsp.sendRedirect(".");
           break;
       case resetDefaultsButton:
           updateSearchCache(getDefaultFilters());
           rsp.sendRedirect(".");
           break;
       default:
           throw new IOException("Action "+action+" is not supported");
   } 
}
 
開發者ID:synopsys-arc-oss,項目名稱:dynamic-search-view-plugin,代碼行數:21,代碼來源:SimpleSearchView.java

示例14: getLabel

import hudson.model.Hudson; //導入依賴的package包/類
/**
 * Get the default Slave Info Label as Hudson {@link hudson.model.Label}
 * @return
 */
private Label getLabel() {
    Label label = null;
    // get mesos cloud
    MesosCloud cloud = MesosCloud.get();
    if(cloud != null) {
        // get all label associate  with cloud
        List<MesosSlaveInfo> list = cloud.getSlaveInfos();
        if(list != null && list.size() > 0) {
            for (MesosSlaveInfo slaveInfo: list) {
                if (slaveInfo.isDefaultSlave()) {
                    label = Hudson.getInstance().getLabel(slaveInfo.getLabelString());
                    break;
                }
            }
        }
    }
    return label;
}
 
開發者ID:jenkinsci,項目名稱:mesos-plugin,代碼行數:23,代碼來源:MesosItemListener.java

示例15: terminate

import hudson.model.Hudson; //導入依賴的package包/類
public void terminate() {
  LOGGER.info("Terminating slave " + getNodeName());
  try {
    // Remove the node from hudson.
    Hudson.getInstance().removeNode(this);

    ComputerLauncher launcher = getLauncher();

    // If this is a mesos computer launcher, terminate the launcher.
    if (launcher instanceof MesosComputerLauncher) {
      ((MesosComputerLauncher) launcher).terminate();
    }
  } catch (IOException e) {
    LOGGER.log(Level.WARNING, "Failed to terminate Mesos instance: "
        + getInstanceId(), e);
  }
}
 
開發者ID:jenkinsci,項目名稱:mesos-plugin,代碼行數:18,代碼來源:MesosSlave.java


注:本文中的hudson.model.Hudson類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。