Example #1
0
  /**
   * Provides additional variables and their values to {@link Builder}s.
   *
   * <p>This mechanism is used by {@link MatrixConfiguration} to pass the configuration values to
   * the current build. It is up to {@link Builder}s to decide whether it wants to recognize the
   * values or how to use them.
   *
   * <p>This also includes build parameters if a build is parameterized.
   *
   * @return The returned map is mutable so that subtypes can put more values.
   */
  public Map<String, String> getBuildVariables() {
    Map<String, String> r = new HashMap<String, String>();

    ParametersAction parameters = getAction(ParametersAction.class);
    if (parameters != null) {
      // this is a rather round about way of doing this...
      for (ParameterValue p : parameters) {
        String v = p.createVariableResolver(this).resolve(p.getName());
        if (v != null) r.put(p.getName(), v);
      }
    }

    // allow the BuildWrappers to contribute additional build variables
    if (project instanceof BuildableItemWithBuildWrappers) {
      for (BuildWrapper bw : ((BuildableItemWithBuildWrappers) project).getBuildWrappersList())
        bw.makeBuildVariables(this, r);
    }

    return r;
  }