public Collection<? extends Action> getProjectActions(final AbstractProject<?, ?> project) {
   Collection<Action> actions = new ArrayList<Action>();
   for (BuildStep publisher : getPublisherList()) {
     actions.addAll(publisher.getProjectActions(project));
   }
   return actions;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
  protected List<Action> createTransientActions() {
    List<Action> r = super.createTransientActions();

    // Fix for ISSUE-1149
    for (MavenModule module : modules.values()) {
      module.updateTransientActions();
    }

    if (publishers
        != null) // this method can be loaded from within the onLoad method, where this might be
                 // null
    for (BuildStep step : publishers) r.addAll(step.getProjectActions(this));

    if (buildWrappers != null)
      for (BuildWrapper step : buildWrappers) r.addAll(step.getProjectActions(this));

    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()});
     }
   }
 }
Ejemplo n.º 5
0
 /** Calls a build step. */
 protected final boolean perform(BuildStep bs, BuildListener listener)
     throws InterruptedException, IOException {
   BuildStepMonitor mon;
   try {
     mon = bs.getRequiredMonitorService();
   } catch (AbstractMethodError e) {
     mon = BuildStepMonitor.BUILD;
   }
   return mon.perform(bs, AbstractBuild.this, launcher, listener);
 }
Ejemplo n.º 6
0
 protected final boolean preBuild(BuildListener listener, Iterable<? extends BuildStep> steps) {
   for (BuildStep bs : steps) if (!bs.prebuild(AbstractBuild.this, listener)) return false;
   return true;
 }