示例#1
0
 /**
  * Runs all the given build steps, even if one of them fail.
  *
  * @param phase true for the post build processing, and false for the final "run after finished"
  *     execution.
  */
 protected final boolean performAllBuildSteps(
     BuildListener listener, Iterable<? extends BuildStep> buildSteps, boolean phase)
     throws InterruptedException, IOException {
   boolean r = true;
   for (BuildStep bs : buildSteps) {
     if ((bs instanceof Publisher && ((Publisher) bs).needsToRunAfterFinalized()) ^ phase)
       try {
         r &= perform(bs, listener);
       } catch (Exception e) {
         String msg = "Publisher " + bs.getClass().getName() + " aborted due to exception";
         e.printStackTrace(listener.error(msg));
         LOGGER.log(Level.WARNING, msg, e);
         setResult(Result.FAILURE);
       }
   }
   return r;
 }
 @SuppressWarnings("rawtypes")
 @Override
 public void buildDependencyGraph(AbstractProject owner, DependencyGraph graph) {
   // As DependecyDeclarer was renamed to DependencyDeclarer in Jenkins 1.501,
   // codes referring DependecyDeclarer may not work depending on which version of
   // Jenkins core used.
   // Instead, I use DescribableList#buildDependencyGraph, which is a part of
   // Jenkins core and always work.
   // See JENKINS-25017 for details.
   for (BuildStep publisher : getPublisherList()) {
     if (publisher instanceof Publisher) {
       DescribableList<Publisher, Descriptor<Publisher>> lst =
           new DescribableList<Publisher, Descriptor<Publisher>>(
               new Saveable() {
                 @Override
                 public void save() throws IOException {}
               },
               Arrays.asList((Publisher) publisher));
       lst.buildDependencyGraph(
           owner, new ConditionalDependencyGraphWrapper(graph, condition, runner));
     } else if (publisher instanceof Builder) {
       // Case used with Any Build Step plugin
       // (https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin).
       DescribableList<Builder, Descriptor<Builder>> lst =
           new DescribableList<Builder, Descriptor<Builder>>(
               new Saveable() {
                 @Override
                 public void save() throws IOException {}
               },
               Arrays.asList((Builder) publisher));
       lst.buildDependencyGraph(
           owner, new ConditionalDependencyGraphWrapper(graph, condition, runner));
     } else if (publisher instanceof DependecyDeclarer) {
       ((DependecyDeclarer) publisher)
           .buildDependencyGraph(
               owner, new ConditionalDependencyGraphWrapper(graph, condition, runner));
     } else {
       LOGGER.log(
           Level.WARNING,
           "May failed to build dependency for {0} in {1}",
           new Object[] {publisher.getClass(), owner.getFullName()});
     }
   }
 }