@SuppressWarnings("UnusedDeclaration")
 public ListBoxModel doFillWorseThanOrEqualToItems() {
   ListBoxModel items = new ListBoxModel();
   items.add("Success", Result.SUCCESS.toString());
   items.add("Unstable", Result.UNSTABLE.toString());
   items.add("Failure", Result.FAILURE.toString());
   items.add("Not Built", Result.NOT_BUILT.toString());
   items.add("Aborted", Result.ABORTED.toString());
   return items;
 }
Ejemplo n.º 2
0
  @Extension
  // for some reason when running mvn from commandline the build fails,
  // if BuildTrigger is not fully qualified here!?
  public static class DescriptorImpl extends hudson.tasks.BuildTrigger.DescriptorImpl {

    public static final String[] THRESHOLD_VALUES = {
      Result.SUCCESS.toString(), Result.UNSTABLE.toString(),
      Result.FAILURE.toString(), Result.ABORTED.toString()
    };

    public static final Strategy[] STRATEGY_VALUES = Strategy.values();

    @Override
    public String getDisplayName() {
      return hudson.plugins.downstream_ext.Messages.DownstreamTrigger_DisplayName();
    }

    @Override
    public String getHelpFile() {
      return "/plugin/downstream-ext/help.html";
    }

    @Override
    public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
      return new DownstreamTrigger(
          formData.getString("childProjects"),
          formData.getString("threshold"),
          formData.has("onlyIfSCMChanges") && formData.getBoolean("onlyIfSCMChanges"),
          formData.getString("strategy"),
          formData.has("triggerOnlyOnceWhenMatrixEnds")
              && formData.getBoolean("triggerOnlyOnceWhenMatrixEnds"));
    }

    public boolean isMatrixProject(AbstractProject project) {
      return project instanceof MatrixProject;
    }

    @Extension
    public static class ItemListenerImpl extends ItemListener {
      @Override
      public void onRenamed(Item item, String oldName, String newName) {
        // update DownstreamTrigger of other projects that point to this object.
        // can't we generalize this?
        for (Project<?, ?> p : Hudson.getInstance().getProjects()) {
          DownstreamTrigger t = p.getPublishersList().get(DownstreamTrigger.class);
          if (t != null) {
            if (t.onJobRenamed(oldName, newName)) {
              try {
                p.save();
              } catch (IOException e) {
                LOGGER.log(
                    Level.WARNING,
                    "Failed to persist project setting during rename from "
                        + oldName
                        + " to "
                        + newName,
                    e);
              }
            }
          }
        }
      }

      @Override
      public void onDeleted(Item item) {
        executors.remove(item);
      }
    }
  }