/** * Converts to the ID string representation: * <tt>axisName=value,axisName=value,...</tt> * * @param sep1 * The separator between multiple axes. * @param sep2 * The separator between axis name and value. */ public String toString(char sep1, char sep2) { StringBuilder buf = new StringBuilder(); for (Map.Entry<String,String> e : entrySet()) { if(buf.length()>0) buf.append(sep1); buf.append(e.getKey()).append(sep2).append(e.getValue()); } if(buf.length()==0) buf.append("default"); // special case to avoid 0-length name. return buf.toString(); }
public int compareTo(Combination that) { int d = this.size()-that.size(); if(d!=0) return d; Iterator<Map.Entry<String,String>> itr = this.entrySet().iterator(); Iterator<Map.Entry<String,String>> jtr = that.entrySet().iterator(); while(itr.hasNext()) { Map.Entry<String,String> i = itr.next(); Map.Entry<String,String> j = jtr.next(); d = i.getKey().compareTo(j.getKey()); if(d!=0) return d; d = i.getValue().compareTo(j.getValue()); if(d!=0) return d; } return 0; }
public int compareTo(Combination that) { int d = this.size()-that.size(); if(d!=0) return d; Iterator<Map.Entry<String,String>> itr = this.entrySet().iterator(); Iterator<Map.Entry<String,String>> jtr = that.entrySet().iterator(); while(itr.hasNext()) { Map.Entry<String,String> i = itr.next(); Map.Entry<String,String> j = jtr.next(); d = i.getKey().compareTo(j.getKey()); if(d!=0) return d; d = i.getValue().compareTo(j.getValue()); if(d!=0) return d; } return 0; }
public int compareTo(Combination that) { int d = this.size()-that.size(); if(d!=0) return d; Iterator<Map.Entry<String,String>> itr = this.entrySet().iterator(); Iterator<Map.Entry<String,String>> jtr = that.entrySet().iterator(); while(itr.hasNext()) { Map.Entry<String,String> i = itr.next(); Map.Entry<String,String> j = jtr.next(); d = i.getKey().compareTo(j.getKey()); if(d!=0) return d; d = i.getValue().compareTo(j.getValue()); if(d!=0) return d; } return 0; }
public File getRootDirFor(Combination combination) { File f = getConfigurationsDir(); for (Entry<String, String> e : combination.entrySet()) f = new File(f,"axis-"+e.getKey()+'/'+Util.rawEncode(e.getValue())); f.getParentFile().mkdirs(); return f; }
public File getRootDirFor(Combination combination) { File f = getConfigurationsDir(); for (Entry<String, String> e : combination.entrySet()) { f = new File(f, "axis-" + e.getKey() + '/' + Util.rawEncode(e.getValue())); } f.getParentFile().mkdirs(); return f; }
public int compareTo(Combination that) { int d = this.size()-that.size(); if(d!=0) return d; Iterator<Map.Entry<String,String>> itr = this.entrySet().iterator(); Iterator<Map.Entry<String,String>> jtr = that.entrySet().iterator(); while(itr.hasNext()) { Map.Entry<String,String> i = itr.next(); Map.Entry<String,String> j = jtr.next(); d = i.getKey().compareTo(j.getKey()); if(d!=0) return d; d = i.getValue().compareTo(j.getValue()); if(d!=0) return d; } return 0; }
public File getRootDirFor(Combination combination) { File f = getConfigurationsDir(); for (Entry<String, String> e : combination.entrySet()) f = new File(f,"axis-"+e.getKey()+'/'+Util.rawEncode(e.getValue())); f.getParentFile().mkdirs(); return f; }
public File getRootDirFor(Combination combination) { File f = getConfigurationsDir(); for (Entry<String, String> e : combination.entrySet()) f = new File(f,"axis-"+e.getKey()+'/'+Util.rawEncode(e.getValue())); f.getParentFile().mkdirs(); return f; }
/** * Gets a root directory for the specified {@link Combination}. * Creates the whole directory hierarchy on-demand. * @param combination Combination to be checked * @return Root directory for the combination */ @Nonnull public File getRootDirFor(@Nonnull Combination combination) { File f = getConfigurationsDir(); for (Entry<String, String> e : combination.entrySet()) f = new File(f,"axis-"+e.getKey()+'/'+Util.rawEncode(e.getValue())); if (!f.getParentFile().exists() && !f.getParentFile().mkdirs()) { LOGGER.log(Level.WARNING, "Cannot create directory {0} for the combination {1}", new Object[]{f, combination}); } return f; }
public static void addMatrixCombination(Run<?, ?> build, ArtifactoryClientConfiguration configuration) { if (build.getParent() instanceof MatrixConfiguration) { Combination combination = ((MatrixConfiguration) build.getParent()).getCombination(); for (Map.Entry<String, String> entries : combination.entrySet()) { configuration.info.addRunParameters(entries.getKey(), entries.getValue()); } } } }
/** * Evaluates the given Groovy expression with values bound from this combination. * * <p> * For example, if this combination is a=X,b=Y, then expressions like <tt>a=="X"</tt> would evaluate to * true. */ public boolean evalGroovyExpression(AxisList axes, String expression) { if(Util.fixEmptyAndTrim(expression)==null) return true; Binding binding = new Binding(); for (Map.Entry<String, String> e : entrySet()) binding.setVariable(e.getKey(),e.getValue()); binding.setVariable("index",toModuloIndex(axes)); binding.setVariable("uniqueId",toIndex(axes)); GroovyShell shell = new GroovyShell(binding); Object result = shell.evaluate("use("+BooleanCategory.class.getName().replace('$','.')+") {"+expression+"}"); return TRUE.equals(result); }
/** * Evaluates the given Groovy expression with values bound from this combination. * * <p> * For example, if this combination is a=X,b=Y, then expressions like <tt>a=="X"</tt> would evaluate to * true. */ public boolean evalGroovyExpression(AxisList axes, String expression) { if(Util.fixEmptyAndTrim(expression)==null) return true; Binding binding = new Binding(); for (Map.Entry<String, String> e : entrySet()) binding.setVariable(e.getKey(),e.getValue()); binding.setVariable("index",toModuloIndex(axes)); binding.setVariable("uniqueId",toIndex(axes)); GroovyShell shell = new GroovyShell(binding); Object result = shell.evaluate("use("+BooleanCategory.class.getName().replace('$','.')+") {"+expression+"}"); return TRUE.equals(result); }
@Override public Map<String,String> getBuildVariables() { Map<String,String> r = super.getBuildVariables(); // pick up user axes AxisList axes = getParent().getParent().getAxes(); for (Map.Entry<String,String> e : getParent().getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a!=null) a.addBuildVariable(e.getValue(),r); else r.put(e.getKey(), e.getValue()); } return r; }
@Override public EnvVars getEnvironment(Node node, TaskListener listener) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(node, listener); AxisList axes = getParent().getAxes(); for (Map.Entry<String,String> e : getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a!=null) a.addBuildVariable(e.getValue(),env); // TODO: hijacking addBuildVariable but perhaps we need addEnvVar? else env.put(e.getKey(), e.getValue()); } return env; }
/** * @since 2.1.0 */ @Override protected void customizeBuildVariables(final Map<String, String> vars) { AxisList axes = getParent().getParent().getAxes(); for (Map.Entry<String,String> e : getParent().getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a!=null) { a.addBuildVariable(e.getValue(),vars); }else { vars.put(e.getKey(), e.getValue()); } } }
/** * @since 2.1.0 */ @Override protected void customizeBuildVariables(final Map<String, String> vars) { AxisList axes = getParent().getParent().getAxes(); for (Map.Entry<String, String> e : getParent().getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a != null) { a.addBuildVariable(e.getValue(), vars); } else { vars.put(e.getKey(), e.getValue()); } } }
/** * @since 2.1.0 */ @Override protected void customizeBuildVariables(final Map<String, String> vars) { AxisList axes = getParent().getParent().getAxes(); for (Map.Entry<String,String> e : getParent().getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a!=null) { a.addBuildVariable(e.getValue(),vars); }else { vars.put(e.getKey(), e.getValue()); } } }
/** * @since 2.1.0 */ @Override protected void customizeBuildVariables(final Map<String, String> vars) { AxisList axes = getParent().getParent().getAxes(); for (Map.Entry<String,String> e : getParent().getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a!=null) { a.addBuildVariable(e.getValue(),vars); }else { vars.put(e.getKey(), e.getValue()); } } }
/*package*/ boolean apply(AxisList axes, Combination c, Binding binding) { for (Map.Entry<String, String> e : c.entrySet()) binding.setVariable(e.getKey(),e.getValue()); binding.setVariable("index",toModuloIndex(axes,c)); binding.setVariable("uniqueId", c.toIndex(axes)); return evaluate(binding); }