com.tikal.jenkins.plugins.multijob.FileBuildParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jenkins-multijob-plugin Show documentation
Show all versions of jenkins-multijob-plugin Show documentation
Enabling full hierarchy of Jenkins jobs
The newest version!
package com.tikal.jenkins.plugins.multijob;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.StringParameterValue;
import hudson.model.TaskListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.tools.ant.filters.StringInputStream;
import org.kohsuke.stapler.DataBoundConstructor;
public class FileBuildParameters extends AbstractBuildParameters {
private final String propertiesFile;
@DataBoundConstructor
public FileBuildParameters(String propertiesFile) {
this.propertiesFile = propertiesFile;
}
public Action getAction(AbstractBuild,?> build, TaskListener listener, AbstractProject project)
throws IOException, InterruptedException {
EnvVars env = build.getEnvironment(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 values = new ArrayList();
for (Map.Entry
© 2015 - 2024 Weber Informatics LLC | Privacy Policy