javaposse.jobdsl.Run Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of job-dsl-core Show documentation
Show all versions of job-dsl-core Show documentation
Javaposse jenkins job-dsl-core
package javaposse.jobdsl;
import javaposse.jobdsl.dsl.DslScriptLoader;
import javaposse.jobdsl.dsl.FileJobManagement;
import javaposse.jobdsl.dsl.GeneratedJob;
import javaposse.jobdsl.dsl.ScriptRequest;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
* Able to run from the command line to test out. Leverage FileJobManagement
*/
public class Run {
public static void main(String[] args) throws Exception {
if(args.length == 0) {
throw new RuntimeException("Script name is required");
}
File cwd = new File(".");
URL cwdURL = cwd.toURI().toURL();
FileJobManagement jm = new FileJobManagement(cwd);
jm.getParameters().putAll(System.getenv());
for(Map.Entry entry: System.getProperties().entrySet()) {
jm.getParameters().put(entry.getKey().toString(), entry.getValue().toString());
}
Collection scripts = new ArrayList();
for(String arg: args) {
if(arg.startsWith("--")) {
scripts.add(arg);
}
}
for(String scriptName: args) {
ScriptRequest request = new ScriptRequest(scriptName, null, cwdURL, false);
Set generatedJobs = DslScriptLoader.runDslEngine(request, jm);
for(GeneratedJob job: generatedJobs) {
System.out.println("From "+ scriptName + ", Generated: " + job);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy