Java 类hudson.model.Saveable 实例源码

项目:gitea-plugin    文件:GiteaWebhookListener.java   
/**
 * {@inheritDoc}
 */
@Override
public void onChange(Saveable o, XmlFile file) {
    if (!(o instanceof Item)) {
        // must be an Item
        return;
    }
    SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem((Item) o);
    if (item == null) {
        // more specifically must be an SCMTriggerItem
        return;
    }
    SCMTrigger trigger = item.getSCMTrigger();
    if (trigger == null || trigger.isIgnorePostCommitHooks()) {
        // must have the trigger enabled and not opted out of post commit hooks
        return;
    }
    for (SCM scm : item.getSCMs()) {
        if (scm instanceof GitSCM) {
            // we have a winner
            GiteaWebhookListener.register(item, (GitSCM) scm);
        }
    }
}
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGateSaveableListener.java   
@Override
public void onChange(Saveable o, XmlFile file) {

    LOG.fine(">>> MirrorGateSaveableListener onChange starts");

    if (o instanceof Job) {
        Job job = (Job) o;
        if (!job.isBuildable()) {
            helper.sendBuildFromJob(job);
        }
    }

    super.onChange(o, file);

    LOG.fine(">>> MirrorGateSaveableListener onChange ends");
}
项目:jenkins-github-pull-request-comments    文件:GhprcTrigger.java   
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    cron = formData.getString("cron");
    outputFile = formData.getString("outputFile");
    unstableAs = GHCommitState.valueOf(formData.getString("unstableAs"));
    autoCloseFailedPullRequests = formData.getBoolean("autoCloseFailedPullRequests");
    displayBuildErrorsOnDownstreamBuilds = formData.getBoolean("displayBuildErrorsOnDownstreamBuilds");

    githubAuth = req.bindJSONToList(GhprcGitHubAuth.class, formData.get("githubAuth"));

    extensions = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP);

    try {
        extensions.rebuildHetero(req, formData, getGlobalExtensionDescriptors(), "extensions");
    } catch (IOException e) {
        e.printStackTrace();
    }

    readBackFromLegacy();

    save();
    return super.configure(req, formData);
}
项目:yaml-project-plugin    文件:FilteredDescribableList.java   
/**
 * Walk the fields of an {@code object} via reflection and populate fields
 * of type {@link DescribableList} with a {@link FilteredDescribableList}
 * with the provided {@link Predicate}.
 */
public static void rewrite(Object object, Predicate predicate) {
  // TODO(mattmoor): This should be recursive.
  for (Class<?> clazz = object.getClass(); clazz != null;
       clazz = clazz.getSuperclass()) {
    for (Field field : clazz.getDeclaredFields()) {
      if (DescribableList.class.isAssignableFrom(field.getType())) {
        try {
          field.setAccessible(true);
          DescribableList list = (DescribableList) field.get(object);
          checkState(list == null || list.size() == 0);

          field.set(object, new FilteredDescribableList(
              predicate, (Saveable) object));
        } catch (IllegalAccessException e) {
          // Impossible, we have given ourselves access.
        }
      }
    }
  }
}
项目:DotCi    文件:DescribableListConverter.java   
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
    if (fromDBObject == null) return null;

    BasicDBList rawList = (BasicDBList) fromDBObject;

    List list = new ArrayList();
    for (Object obj : rawList) {
        DBObject dbObj = (DBObject) obj;
        list.add(getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache()));
    }

    Saveable owner = null; // TODO figure out how to associate the deserialized project here

    return new DescribableList(owner, list);
}
项目:delivery-pipeline-plugin    文件:PipelineTest.java   
@Test
public void testForkJoin() throws Exception {
    FreeStyleProject projectA = jenkins.createFreeStyleProject("A");
    FreeStyleProject projectB = jenkins.createFreeStyleProject("B");
    FreeStyleProject projectC = jenkins.createFreeStyleProject("C");
    FreeStyleProject projectD = jenkins.createFreeStyleProject("D");
    projectA.getPublishersList().add(new BuildTrigger("B,C", false));
    projectB.getPublishersList().add(new BuildTrigger("D", false));
    projectC.getPublishersList().add(new BuildTrigger("D", false));
    projectD.getPublishersList().add(
            new JoinTrigger(new DescribableList<>(Saveable.NOOP), "", false));
    jenkins.getInstance().rebuildDependencyGraph();
    Pipeline prototype = Pipeline.extractPipeline("ForkJoin", projectA);
    assertNotNull(prototype);
    assertEquals(4, prototype.getStages().size());

    assertEquals(0, prototype.getStages().get(0).getColumn());
    assertEquals(0, prototype.getStages().get(0).getRow());
    assertEquals(1, prototype.getStages().get(1).getColumn());
    assertEquals(0, prototype.getStages().get(1).getRow());
    assertEquals(2, prototype.getStages().get(2).getColumn());
    assertEquals(0, prototype.getStages().get(2).getRow());
    assertEquals(1, prototype.getStages().get(3).getColumn());
    assertEquals(1, prototype.getStages().get(3).getRow());
}
项目:mesos-plugin    文件:Mesos.java   
@Override
public void onChange(Saveable o, XmlFile file) {
  if (o instanceof Jenkins) {
    Jenkins j = (Jenkins) o;
    Set<String> jenkinsClouds = new HashSet<String>();
    for (Cloud c : j.clouds){
      if (c instanceof MesosCloud) {
        jenkinsClouds.add(((MesosCloud) c).getCloudID());
      }
    }
    for (Iterator<Map.Entry<String, Mesos>> it = clouds.entrySet().iterator(); it.hasNext();) {
      Map.Entry<String, Mesos> entry = it.next();
      if(!jenkinsClouds.contains(entry.getKey())) {
        LOGGER.info("Removing active scheduler because cloud was removed");
        entry.getValue().stopScheduler(true);
        it.remove();
      }
      }
      }
  }
项目:gearman-plugin    文件:SaveableListenerImpl.java   
@Override
// This works but is NOT good because this event is a catch all
// for just about any change that happens in Jenkins. This event
// also doesn't provide much detail on what has changed.
public void onChange(Saveable o, XmlFile file) {
    // update functions only when gearman-plugin is enabled
    if (!GearmanPluginConfig.get().enablePlugin()) {
        return;
    }

    // only look for changes to projects, specifically for project
    // label changes.  Node changes are handled in ComputerListenerImpl
    if (o instanceof AbstractProject) {
        GearmanProxy.getInstance().registerJobs();
    }
}
项目:jenkins-github-pull-request-comments    文件:GhprcTrigger.java   
public DescribableList<GhprcExtension, GhprcExtensionDescriptor> getExtensions() {
    if (extensions == null) {
        extensions = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP,Util.fixNull(extensions));
        extensions.add(new GhprcSimpleStatus());
    }
    return extensions;
}
项目:jenkins-github-pull-request-comments    文件:GhprcTrigger.java   
private void setExtensions(List<GhprcExtension> extensions) {
    DescribableList<GhprcExtension, GhprcExtensionDescriptor> rawList = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(
            Saveable.NOOP,Util.fixNull(extensions));

    // Filter out items that we only want one of, like the status updater.
    this.extensions = Ghprc.onlyOneEntry(rawList,
            GhprcCommitStatus.class
    );

    // Now make sure we have at least one of the types we need one of.
    Ghprc.addIfMissing(this.extensions, new GhprcSimpleStatus(), GhprcCommitStatus.class);
}
项目:jenkins-github-pull-request-comments    文件:Ghprc.java   
private static DescribableList<GhprcExtension, GhprcExtensionDescriptor> copyExtensions(DescribableList<GhprcExtension, GhprcExtensionDescriptor> ...extensionsList){
    DescribableList<GhprcExtension, GhprcExtensionDescriptor> copiedList = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP);
    for (DescribableList<GhprcExtension, GhprcExtensionDescriptor> extensions: extensionsList) {
        copiedList.addAll(extensions);
    }
    return copiedList;
}
项目:jenkins-github-pull-request-comments    文件:Ghprc.java   
public static DescribableList<GhprcExtension, GhprcExtensionDescriptor> onlyOneEntry(DescribableList<GhprcExtension, GhprcExtensionDescriptor> extensions, Class<?> ...types) {
    DescribableList<GhprcExtension, GhprcExtensionDescriptor> copyExtensions = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP);

    Set<Class<?>> extSet = new HashSet<Class<?>>(types.length);
    List<Predicate> predicates = createPredicate(types);
    for (GhprcExtension extension: extensions) {
        if (addExtension(extension, predicates, extSet)) {
            copyExtensions.add(extension);
        }
    }

    return copyExtensions;
}
项目:DotCi-Plugins-Starter-Pack    文件:JunitPluginAdapter.java   
@Override
public boolean perform(DynamicBuild dynamicBuild, Launcher launcher, BuildListener listener) {
  String files = getPluginInputFiles();
  listener.getLogger().println(String.format("Archiving JUnit results: '%s'", files));

  DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>> testDataPublishers = new DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>>(Saveable.NOOP);
  JUnitResultArchiver publisher = new JUnitResultArchiver(files, true, testDataPublishers);
  try {
    return publisher.perform(((AbstractBuild) dynamicBuild), launcher, listener);
  } catch (Exception e) {
    listener.getLogger().println(String.format("FAILED archiving JUnit results: %s", e.toString()));
    return false;
  }
}
项目:aws-beanstalk-publisher    文件:AWSEBBuilder.java   
@DataBoundConstructor
public AWSEBBuilder(
        List<AWSEBElasticBeanstalkSetup> extensions) {
    super();
    this.extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(
            Saveable.NOOP,Util.fixNull(extensions));
}
项目:aws-beanstalk-publisher    文件:AWSEBElasticBeanstalkSetup.java   
@DataBoundConstructor
public AWSEBElasticBeanstalkSetup(
        Regions awsRegion, 
        String awsRegionText, 
        String credentialsString,
        String credentialsText,
        String applicationName, 
        String versionLabelFormat, 
        Boolean failOnError,
        List<AWSEBSetup> extensions,
        List<AWSEBSetup> envLookup) {

    this.awsRegion = awsRegion;
    this.awsRegionText = awsRegionText;
    this.credentialsString = credentialsString;
    this.credentialsText = credentialsText;
    this.applicationName = applicationName;

    this.versionLabelFormat = versionLabelFormat;
    this.failOnError = failOnError;
    this.extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP, Util.fixNull(extensions));

    this.envLookup = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP, Util.fixNull(envLookup));
    if (this.envLookup.size() == 0){
        this.envLookup.add(new ByName(""));
    }
}
项目:aws-beanstalk-publisher    文件:AWSEBPublisher.java   
@DataBoundConstructor
public AWSEBPublisher(
        List<AWSEBElasticBeanstalkSetup> extensions) {
    super();
    this.extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(
            Saveable.NOOP,Util.fixNull(extensions));
}
项目:jenkins.py    文件:SaveableListenerPW.java   
@Override
public void onChange(Saveable o, XmlFile file) {
    initPython();
    if (pexec.isImplemented(0)) {
        pexec.execPythonVoid("on_change", o, file);
    } else {
        super.onChange(o, file);
    }
}
项目:rabbitmq-consumer-plugin    文件:SaveableListenerImpl.java   
@Override
public final void onChange(Saveable o, XmlFile file) {
    if (o instanceof GlobalRabbitmqConfiguration) {
        LOGGER.info("RabbitMQ configuration is updated, so update connection...");
        RMQManager.getInstance().update();
    }
    super.onChange(o, file);
}
项目:jira-ext-plugin    文件:JiraExtPublisherStep.java   
@DataBoundConstructor
public JiraExtPublisherStep(IssueStrategyExtension issueStrategy, List<JiraOperationExtension> extensions)
{
    this.issueStrategy = issueStrategy;
    this.extensions = new DescribableList<>(Saveable.NOOP, Util.fixNull(extensions));
}
项目:jenkins-github-pull-request-comments    文件:GhprcTrigger.java   
public DescribableList<GhprcExtension, GhprcExtensionDescriptor> getExtensions() {
    if (extensions == null) {
        extensions = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP);
    }
    return extensions;
}
项目:multi-branch-project-plugin    文件:TemplateDrivenMultiBranchProject.java   
@Override
public void onChange(Saveable o, XmlFile file) {
    if (o instanceof Item) {
        enforceProjectStateOnUpdated((Item) o);
    }
}
项目:yaml-project-plugin    文件:FilteredDescribableList.java   
public FilteredDescribableList(
    Predicate<Descriptor<T>> filter, Saveable owner) {
  super(owner);
  this.filter = checkNotNull(filter);
}
项目:aws-beanstalk-publisher    文件:AWSEBBuilder.java   
public DescribableList<AWSEBSetup, AWSEBSetupDescriptor> getExtensions() {
    if (extensions == null) {
        extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP,Util.fixNull(extensions));
    }
    return extensions;
}
项目:aws-beanstalk-publisher    文件:AWSEBElasticBeanstalkSetup.java   
public DescribableList<AWSEBSetup, AWSEBSetupDescriptor> getExtensions() {
    if (extensions == null) {
        extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP, Util.fixNull(extensions));
    }
    return extensions;
}
项目:aws-beanstalk-publisher    文件:AWSEBElasticBeanstalkSetup.java   
public DescribableList<AWSEBSetup, AWSEBSetupDescriptor> getEnvLookup() {
    if (envLookup == null) {
        envLookup = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP, Util.fixNull(envLookup));
    }
    return envLookup;
}
项目:aws-beanstalk-publisher    文件:AWSEBPublisher.java   
public DescribableList<AWSEBSetup, AWSEBSetupDescriptor> getExtensions() {
    if (extensions == null) {
        extensions = new DescribableList<AWSEBSetup, AWSEBSetupDescriptor>(Saveable.NOOP,Util.fixNull(extensions));
    }
    return extensions;
}
项目:p4-jenkins    文件:ConfigurationListener.java   
public void onChange(Saveable o, XmlFile xml) {
    Jenkins j = Jenkins.getInstance();
    if (j == null) {
        return;
    }

    @SuppressWarnings("unchecked")
    Descriptor<SCM> scm = j.getDescriptor(PerforceScm.class);
    DescriptorImpl p4scm = (DescriptorImpl) scm;

    // Exit early if disabled
    if (!p4scm.isAutoSave()) {
        return;
    }

    try {
        String file = xml.getFile().getCanonicalPath();
        logger.info(">>> onUpdated: " + file);

        // create Publish object
        String desc = "Configuration change";
        boolean success = false;
        boolean delete = true;
        boolean reopen = false;
        String purge = "";
        SubmitImpl publish = new SubmitImpl(desc, success, delete, reopen, purge);

        ClientHelper p4 = getClientHelper(p4scm);
        int ChangelistID = -1;

        if (!p4scm.isAutoSubmitOnChange()) {
            ChangelistID = p4.findPendingChangelistIDByDesc(desc, p4scm.getClientName());
        }
        p4.versionFile(file, publish, ChangelistID, p4scm.isAutoSubmitOnChange());

        p4.disconnect();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:jenkins.py    文件:SaveableListenerPW.java   
public void superOnChange(Saveable o, XmlFile file) {
    super.onChange(o, file);
}
项目:jenkins-inheritance-plugin    文件:SimplifiedViewDescribableList.java   
public SimplifiedViewDescribableList(
        Saveable owner, Collection<? extends T> initialList) {
    super(owner, initialList);
}