Java 类hudson.model.Hudson 实例源码

项目:CI-Jenkins-Plugin    文件:GitHubTargetParameterAction.java   
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("../");
}
项目:ec2-plugin    文件:EC2OndemandSlave.java   
@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;
}
项目:ec2-plugin    文件:EC2SlaveMonitor.java   
@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);
            }
        }
    }
}
项目:ec2-plugin    文件:EC2Cloud.java   
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);
    }
}
项目:ec2-plugin    文件:ZPoolMonitor.java   
@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;
   }
项目:ec2-plugin    文件:AmazonEC2Cloud.java   
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();
}
项目:deployer-framework-plugin    文件:DeployNowProjectAction.java   
/**
 * 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;
}
项目:deployer-framework-plugin    文件:DeployTargetDescriptor.java   
/**
 * 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;
}
项目:deployer-framework-plugin    文件:DeployNowRunAction.java   
@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;
}
项目:openshift-deployer-plugin    文件:BaseJenkinsTest.java   
@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);
    }
}
项目:fauxpas-jenkins-plugin    文件:FauxPasAppToolInstallation.java   
@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();
}
项目:ccr-parameter-plugin    文件:CacheManager.java   
/**
 * 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);
    }
}
项目:dynamic-search-view-plugin    文件:SimpleSearchView.java   
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");
   } 
}
项目:mesos-plugin    文件:MesosItemListener.java   
/**
 * 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;
}
项目:mesos-plugin    文件:MesosSlave.java   
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);
  }
}
项目:kpp-management-plugin    文件:KPPManagementLink.java   
/**
 * Action method if upload button is clicked.
 * 
 * @param req Request
 * @param rsp Response
 * @throws ServletException
 * @throws IOException
 * @throws NoSuchAlgorithmException 
 */
public void doUploadFile(StaplerRequest req, StaplerResponse rsp) throws
        ServletException,
        IOException,
        NoSuchAlgorithmException {
    Hudson.getInstance().checkPermission(Hudson.ADMINISTER);

    FileItem file = req.getFileItem("file");
    if (file == null || file.getSize() == 0) {
        this.errorMessage = Messages.KPPManagementLink_Upload_Error_NoFile();
    } else {
        KPPKeychainsProvider kProvider = KPPKeychainsProvider.getInstance();
        KPPProvisioningProfilesProvider ppProvider = KPPProvisioningProfilesProvider.getInstance();
        if (kProvider.isKeychainFile(file)) {
            kProvider.upload(file);
            kProvider.update();
        } else if (ppProvider.isMobileProvisionProfileFile(file)) {
            ppProvider.upload(file);
            ppProvider.update();
        } else {
            this.errorMessage = String.format(Messages.KPPManagementLink_Upload_Error_WrongFileType(), file.getName());
        }
    }

    rsp.sendRedirect2("../"+getUrlName()+"/"); //we stay on page
}
项目:kpp-management-plugin    文件:KPPManagementLink.java   
/**
 * Action method if save button is clicked.
 * 
 * @param req Request
 * @param rsp Response
 * @throws ServletException
 * @throws IOException
 * @throws NoSuchAlgorithmException 
 */
public void doSave(StaplerRequest req, StaplerResponse rsp) throws
        ServletException,
        IOException,
        NoSuchAlgorithmException {
    Hudson.getInstance().checkPermission(Hudson.ADMINISTER);

    JSONObject data = req.getSubmittedForm();
    List<KPPKeychain> keychains = req.bindJSONToList(KPPKeychain.class, data.get("keychain"));
    KPPKeychainsProvider.getInstance().updateKeychainsFromSave(keychains);
    List<KPPProvisioningProfile> pps = req.bindJSONToList(KPPProvisioningProfile.class, data.get("profile"));
    KPPProvisioningProfilesProvider.getInstance().updateProvisioningProfilesFromSave(pps);
    KPPProvisioningProfilesProvider.getInstance().setProvisioningProfilesPath(data.getString("provisioningProfilesPath"));
    save();
    rsp.sendRedirect2("../manage"); //we go back on management page
}
项目:kpp-management-plugin    文件:KPPKeychainsBuildWrapper.java   
/**
 * Copy the keychains configured for this build job to the workspace of the job.
 * @param build the current build
 * @throws IOException
 * @throws InterruptedException 
 */
private void copyKeychainsToWorkspace(AbstractBuild build) throws IOException, InterruptedException {
    FilePath projectWorkspace = build.getWorkspace();

    Hudson hudson = Hudson.getInstance();
    FilePath hudsonRoot = hudson.getRootPath();

    if (copiedKeychains == null) {
        copiedKeychains = new ArrayList<FilePath>();
    } else {
        copiedKeychains.clear();
    }

    for (KPPKeychainCertificatePair pair : keychainCertificatePairs) {
        FilePath from = new FilePath(hudsonRoot, pair.getKeychainFilePath());
        FilePath to = new FilePath(projectWorkspace, pair.getKeychainFileName());
        if (overwriteExistingKeychains || !to.exists()) {
            from.copyTo(to);
            copiedKeychains.add(to);
        }
    }
}
项目:jenkins-scala-plugin    文件:AbstractScalaBuilder.java   
/**
 * Returns the Scala Installation that corresponds to the getScalaName()
 *
 * @param logger The logger
 *
 *  @return The ScalaInstallation or null, if no installations are configured.
 */
protected ScalaInstallation getScalaInstallation(final PrintStream logger) {

    ScalaInstallation result = null;

    final ScalaInstallation[] scalaInstallations = Hudson.getInstance().getDescriptorByType(ScalaInstallation.DescriptorImpl.class).getInstallations();
    if(getScalaName().equals("Default")) {
        if(scalaInstallations.length > 0) {
            result = scalaInstallations[0];
            logger.println("[SCALA PLUGIN WARNING] Using Default Scala Installation '" + result.getName() + "'");
        } else {
            logger.println("[SCALA PLUGIN WARNING] Default Scala Installation selected, but no Scala Installations configured. Check your Jenkins Settings!'" + result.getName() + "'");
        }
    } else {
        for(final ScalaInstallation scalaInstallation : scalaInstallations) {
            if(scalaInstallation.getName().equals(getScalaName())) {
                result = scalaInstallation;
                break;
            }
        }
    }

    return result;
}
项目:deepin-oauth-plugin    文件:DeepinOAuthApiService.java   
public DeepinOAuthApiService(String apiKey, String apiSecret) {
    clientID = apiKey;
    clientSecret = apiSecret;
    String rootUrl = Hudson.getInstance().getRootUrl();
    if (StringUtils.endsWith(rootUrl, "/")) {
        rootUrl = StringUtils.left(rootUrl, StringUtils.length(rootUrl) - 1);
    }
    oauthCallback = rootUrl + "/securityRealm/finishLogin";
}
项目:ec2-plugin    文件:SlaveTemplate.java   
/**
 * Since this shares much of the configuration with {@link EC2Computer}, check its help page, too.
 */
@Override
public String getHelpFile(String fieldName) {
    String p = super.getHelpFile(fieldName);
    if (p==null)
        p = Hudson.getInstance().getDescriptor(EC2OndemandSlave.class).getHelpFile(fieldName);
    if (p==null)
        p = Hudson.getInstance().getDescriptor(EC2SpotSlave.class).getHelpFile(fieldName);
    return p;
}
项目:ec2-plugin    文件:EC2SlaveMonitor.java   
private void removeNode(EC2AbstractSlave ec2Slave) {
    try {
        Hudson.getInstance().removeNode(ec2Slave);
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to remove node: " + ec2Slave.getInstanceId());
    }
}
项目:ec2-plugin    文件:PluginImpl.java   
@Override
public void start() throws Exception {
    // backward compatibility with the legacy class name
    Hudson.XSTREAM.alias("hudson.plugins.ec2.EC2Cloud",AmazonEC2Cloud.class);
    Hudson.XSTREAM.alias("hudson.plugins.ec2.EC2Slave",EC2OndemandSlave.class);
    // backward compatibility with the legacy instance type
    Hudson.XSTREAM.registerConverter(new InstanceTypeConverter());

    load();
}
项目:ec2-plugin    文件:EC2Cloud.java   
/**
 * Debug command to attach to a running instance.
 */
public void doAttach(StaplerRequest req, StaplerResponse rsp, @QueryParameter String id) throws ServletException, IOException, AmazonClientException {
    checkPermission(PROVISION);
    SlaveTemplate t = getTemplates().get(0);

    StringWriter sw = new StringWriter();
    StreamTaskListener listener = new StreamTaskListener(sw);
    EC2AbstractSlave node = t.attach(id, listener);
    Hudson.getInstance().addNode(node);

    rsp.sendRedirect2(req.getContextPath() + "/computer/" + node.getNodeName());
}
项目:deployer-framework-plugin    文件:DeployTargetDescriptor.java   
/**
 * If the specified source is null, try to pick the best default to select initially.
 *
 * @param source  the possibly null source.
 * @param origins the origins from which sources can be considered valid.
 * @param jobType the project type.
 * @return either the passed through source, or the (possible {@code null}) best guess default.
 */
@CheckForNull
public DeploySource defaultDeploySource(@CheckForNull DeploySource source,
                                        @CheckForNull Set<DeploySourceOrigin> origins,
                                        @CheckForNull Class<? extends AbstractProject> jobType) {
    if (source != null) {
        return source;
    }
    if (origins != null) {
        for (Descriptor<DeploySource> d : Hudson.getInstance().getDescriptorList(DeploySource.class)) {
            if (d instanceof DeploySourceDescriptor) {
                DeploySourceDescriptor descriptor = (DeploySourceDescriptor) d;
                for (DeploySourceOrigin origin : origins) {
                    if (descriptor.isSupported(origin) && descriptor.isApplicable(jobType)) {
                        if ((isFileTarget() && descriptor.isFileSource())
                                || (isDirectoryTarget() && descriptor.isDirectorySource())) {
                            try {
                                return descriptor.newInstance();
                            } catch (UnsupportedOperationException e) {
                                // ignore
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
项目:deployer-framework-plugin    文件:DeployNowRunAction.java   
/**
 * Returns true if the log file is still being updated.
 */
public boolean isLogUpdated() {
    if (deployer != null) {
        return true;
    }
    for (Queue.Item item : Hudson.getInstance().getQueue().getItems()) {
        if (item.task instanceof DeployNowTask && owner.equals(DeployNowTask.class.cast(item.task).getBuild())) {
            return true;
        }
    }
    return false;
}
项目:grapes-jenkins-plugin    文件:GrapesPlugin.java   
/**
 * Returns the path or URL to access web resources from this plugin.
 *
 * @return resource path
 */
public static String getPluginResourcePath() {
    final PluginWrapper wrapper = Hudson.getInstance().getPluginManager()
            .getPlugin(GrapesPlugin.class);

    return "/plugin/" + wrapper.getShortName() + "/";
}
项目:cloud-jenkins    文件:CloudJenkinsManagementLink.java   
public void doRestore(final StaplerRequest request, final StaplerResponse response) throws IOException,
        ServletException {
    execute(request, response, "", new IORunnable() {
        @Override
        public void run() throws IOException, ServletException {
            getConfigurationFileManager().restoreConfiguration();
            Hudson.getInstance().doReload();
        }
    });
}
项目:cloud-jenkins    文件:CloudJenkinsManagementLink.java   
private void execute(final StaplerRequest request, final StaplerResponse response, final String nextPage,
        final IORunnable runnable) throws IOException, ServletException {
    Hudson.getInstance().checkPermission(Jenkins.ADMINISTER);
    runnable.run();
    if (!response.isCommitted()) {
        response.sendRedirect(request.getContextPath() + "/" + getUrlName() + nextPage);
    }
}
项目:jenkins.py    文件:ExtensionFinderPW.java   
private void initPython() {
    if (pexec == null) {
        pexec = new PythonExecutor(this);
        String[] jMethods = new String[2];
        jMethods[0] = "refresh";
        jMethods[1] = "find";
        String[] pFuncs = new String[2];
        pFuncs[0] = "refresh";
        pFuncs[1] = "find";
        Class[][] argTypes = new Class[2][];
        argTypes[0] = new Class[0];
        argTypes[1] = new Class[2];
        argTypes[1][0] = Class.class;
        argTypes[1][1] = Hudson.class;
        pexec.checkAbstrMethods(jMethods, pFuncs, argTypes);
        String[] functions = new String[4];
        functions[0] = "find_extensions";
        functions[1] = "is_refreshable";
        functions[2] = "_find";
        functions[3] = "scout";
        int[] argsCount = new int[4];
        argsCount[0] = 2;
        argsCount[1] = 0;
        argsCount[2] = 2;
        argsCount[3] = 2;
        pexec.registerFunctions(functions, argsCount);
    }
}
项目:jenkins.py    文件:ExtensionFinderPW.java   
@Override
public <T> Collection<ExtensionComponent<T>> _find(Class<T> type, Hudson hudson) {
    initPython();
    if (pexec.isImplemented(2)) {
        return (Collection) pexec.execPython("_find", type, hudson);
    } else {
        return super._find(type, hudson);
    }
}
项目:jenkins.py    文件:ExtensionFinderPW.java   
@Override
public void scout(Class extensionType, Hudson hudson) {
    initPython();
    if (pexec.isImplemented(3)) {
        pexec.execPythonVoid("scout", extensionType, hudson);
    } else {
        super.scout(extensionType, hudson);
    }
}
项目:git-param    文件:GitParameterDefinition.java   
private AbstractProject<?, ?> getCurrentProject() {
    AbstractProject<?, ?> context = null;
    List<AbstractProject> jobs = Hudson.getInstance().getItems(
            AbstractProject.class);

    for (AbstractProject<?, ?> project : jobs) {
        ParametersDefinitionProperty property = (ParametersDefinitionProperty) project
                .getProperty(ParametersDefinitionProperty.class);

        if (property != null) {
            List<ParameterDefinition> parameterDefinitions = property
                    .getParameterDefinitions();

            if (parameterDefinitions != null) {
                for (ParameterDefinition pd : parameterDefinitions) {

                    if (pd instanceof GitParameterDefinition
                            && ((GitParameterDefinition) pd)
                                    .compareTo(this) == 0) {

                        context = project;
                        break;
                    }
                }
            }
        }
    }

    return context;
}
项目:pipeline-sink-trigger-plugin    文件:BuildGraphPipelineSinkTrigger.java   
private FormValidation validateProjectParemeter(String projectName) throws IOException, ServletException {
    if (projectName.trim().length() == 0) {
        return FormValidation.error(Messages.BuildGraphPipelineSinkTrigger_NoProjectSpecified());
    }
    final Item item = Hudson.getInstance().getItem(projectName);
    if (item == null) {
        return FormValidation.error(Messages.BuildGraphPipelineSinkTrigger_NoSuchProject(projectName));
    }
    if (!AbstractProject.class.isAssignableFrom(item.getClass())) {
        return FormValidation.error(hudson.tasks.Messages.BuildTrigger_NotBuildable(projectName));
    }
    return FormValidation.ok();
}
项目:pipeline-sink-trigger-plugin    文件:BuildGraphPipelineSinkTrigger.java   
@Override
public void onDeleted(Item item) {
    for (Project<?, ?> p : Hudson.getInstance().getProjects()) {
        final BuildGraphPipelineSinkTrigger trigger = p.getTrigger(BuildGraphPipelineSinkTrigger.class);
        if (trigger != null) {
            if (trigger.onJobDeleted(item.getName())) {
                try {
                    p.save();
                } catch (IOException e) {
                    LOGGER.log(Level.WARNING, String.format("Failed to persist project setting during deletion of %s", item.getName()), e);
                }
            }
        }
    }
}
项目:pipeline-sink-trigger-plugin    文件:BuildGraphPipelineSinkTrigger.java   
@Override
public void onRenamed(Item item, String oldName, String newName) {
    for (Project<?, ?> p : Hudson.getInstance().getProjects()) {
        final BuildGraphPipelineSinkTrigger trigger = p.getTrigger(BuildGraphPipelineSinkTrigger.class);
        if (trigger != null) {
            if (trigger.onJobRenamed(oldName, newName)) {
                try {
                    p.save();
                } catch (IOException e) {
                    LOGGER.log(Level.WARNING, String.format("Failed to persist project setting during rename from %s to %s", oldName, newName), e);
                }
            }
        }
    }
}
项目:xldeploy-plugin    文件:RepositoryUtils.java   
public static DeployitServer getDeployitServer(String credentialName, Credential overridingCredential) {
    Credential credential = findCredential(credentialName);
    DeployitDescriptor descriptor = (DeployitDescriptor) Hudson.getInstance().getDescriptor(DeployitNotifier.class);
    if (null != credential && null != overridingCredential) {
        String secondaryProxyUrl = credential.resolveProxyUrl(descriptor.getDeployitClientProxyUrl());
        String secondaryServerUrl = credential.resolveServerUrl(descriptor.getDeployitServerUrl());

        SecondaryServerInfo serverInfo = new SecondaryServerInfo(secondaryServerUrl, secondaryProxyUrl);
        credential = new Credential(credential.getName(), overridingCredential.getUsername(), overridingCredential.getPassword(), overridingCredential.getCredentialsId(), serverInfo, overridingCredential.isUseGlobalCredential());
    }
    DeployitServer deployitServer = descriptor.getDeployitServer(credential);

    return deployitServer;
}
项目:xldeploy-plugin    文件:RepositoryUtils.java   
public static DeployitNotifier retrieveDeployitNotifierFromProject(AbstractProject project) {
    DeployitNotifier notifier = null;
    DeployitDescriptor descriptor = (DeployitDescriptor) Hudson.getInstance().getDescriptor(DeployitNotifier.class);
    if (null != project) {
        notifier = (DeployitNotifier) project.getPublishersList().get(descriptor);
    }
    return notifier;
}
项目:proxmox-plugin    文件:VirtualMachineSlave.java   
public ListBoxModel doFillDatacenterDescriptionItems() {
    ListBoxModel items = new ListBoxModel();
    for (Cloud cloud : Hudson.getInstance().clouds) {
        if (cloud instanceof Datacenter) {
            //TODO: Possibly add the `datacenterDescription` as the `displayName` and `value` (http://javadoc.jenkins-ci.org/hudson/util/ListBoxModel.html)
            //Add by `display name` and then the `value`
            items.add(((Datacenter) cloud).getHostname(), ((Datacenter) cloud).getDatacenterDescription());
        }
    }
    return items;
}
项目:proxmox-plugin    文件:VirtualMachineSlave.java   
private Datacenter getDatacenterByDescription (String datacenterDescription) {
    if (datacenterDescription != null && !datacenterDescription.equals("")) {
        for (Cloud cloud : Hudson.getInstance().clouds) {
            if (cloud instanceof Datacenter && ((Datacenter) cloud).getDatacenterDescription().equals(datacenterDescription)) {
                return (Datacenter) cloud;
            }
        }
    }
    return null;
}