public Object readResolve() { List<AbstractBuildParameters> configs = new ArrayList<AbstractBuildParameters>(); if (includeCurrentParameters) { configs.add(new CurrentBuildParameters()); } if (propertiesFile != null) { configs.add(new FileBuildParameters(propertiesFile)); } return new BuildTriggerConfig(projectsValue, condition, triggerWithNoParameters, configs); } }
/** * This function returns the Action that should be passed to the triggered build * to not trigger the build it can throw the {@link DontTriggerException} * * @return Action to be passed to the triggered build, can be Null if no parameters. */ public Action getAction(AbstractBuild<?,?> build, TaskListener listener) throws IOException, InterruptedException, DontTriggerException{ EnvVars env = getEnvironment(build, listener); String resolvedPropertiesFile = env.expand(propertiesFile); String[] allFiles = Util.tokenize(resolvedPropertiesFile, ","); String[] trimmedFiles = new String[allFiles.length]; for (int i = 0; i < allFiles.length; i++) trimmedFiles[i] = allFiles[i].trim(); List<ParameterValue> values = new ArrayList<ParameterValue>(); // builds to scan. Collection<? extends AbstractBuild<?,?>> targetBuilds = getTargetBuilds(build); for (AbstractBuild<?,?> targetBuild: targetBuilds) { values.addAll(extractAllValues(targetBuild, listener, trimmedFiles)); } //Values might be empty, in that case don't return anything. return values.size() == 0 ? null :new ParametersAction(values); }
private Collection<? extends AbstractBuild<?, ?>> getTargetBuilds(AbstractBuild<?, ?> build) { if ((build instanceof MatrixBuild) && isUseMatrixChild()) { return Collections2.filter( isOnlyExactRuns()?((MatrixBuild)build).getExactRuns():((MatrixBuild)build).getRuns(), new Predicate<MatrixRun>() { public boolean apply(@Nullable MatrixRun run) { if (run == null) { return false; } if (StringUtils.isBlank(getCombinationFilter())) { // no combination filter stands for all children. return true; } Combination c = run.getParent().getCombination(); AxisList axes = run.getParent().getParent().getAxes(); return c.evalGroovyExpression(axes, getCombinationFilter()); } } ); } else { return Arrays.<AbstractBuild<?,?>>asList(build); } }
private List<ParameterValue> extractAllValues(AbstractBuild<?,?> build, TaskListener listener, String[] allFiles) throws IOException, InterruptedException, DontTriggerException { List<ParameterValue> values = new ArrayList<ParameterValue>(); EnvVars env = getEnvironment(build, listener); for(String file:allFiles) { String s = null; FilePath f = workspace.child(file); if (f.exists()) { s = ParameterizedTriggerUtils.readFileToString(f, getEncoding()); listener.getLogger().println(Plugin.LOG_TAG + " Properties file " + file + " did not exist."); if (getFailTriggerOnMissing()) { listener.getLogger().println("Not triggering due to missing file - did you archive it as a build artifact ?"); throw new DontTriggerException();
public Action getAction(AbstractBuild<?,?> build, TaskListener listener) throws IOException, InterruptedException { EnvVars env = getEnvironment(build, listener); String resolvedPropertiesFile = env.expand(propertiesFile); FilePath f = build.getWorkspace().child(resolvedPropertiesFile); if (!f.exists()) { listener .getLogger() .println( "[parameterizedtrigger] Could not trigger downstream project, as properties file " + resolvedPropertiesFile + " did not exist."); return null; } String s = f.readToString(); s = env.expand(s); Properties p = new Properties(); p.load(new StringInputStream(s)); List<ParameterValue> values = new ArrayList<ParameterValue>(); for (Map.Entry<Object, Object> entry : p.entrySet()) { values.add(new StringParameterValue(entry.getKey().toString(), entry.getValue().toString())); } return new ParametersAction(values); }
public boolean apply(@Nullable MatrixRun run) { if (run == null) { return false; } if (StringUtils.isBlank(getCombinationFilter())) { // no combination filter stands for all children. return true; } Combination c = run.getParent().getCombination(); AxisList axes = run.getParent().getParent().getAxes(); return c.evalGroovyExpression(axes, getCombinationFilter()); } }
public Object readResolve() { List<AbstractBuildParameters> configs = new ArrayList<AbstractBuildParameters>(); if (includeCurrentParameters) { configs.add(new CurrentBuildParameters()); } if (propertiesFile != null) { configs.add(new FileBuildParameters(propertiesFile)); } return new BuildTriggerConfig(projectsValue, condition, triggerWithNoParameters, configs); } }