public void CreateJob(JobConfigModel model) { //Instanciate plugins depending on class name Job job = PluginStorage.CreateObject <Job>(model.ClassName); //Load job from config job.LoadConfig(model.GetConfig()); //Create repository configuration in jobs folder job.CreateRepository("jobs"); }
public Config GetConfig() { Config config = new Config(); config.AddProperty( new DescriptionPropertyDefinition(), new Parameter[] { new Parameter() { Definition = new StringParameterDefinition(), Name = "name", Value = Name }, new Parameter() { Definition = new StringParameterDefinition(), Name = "description", Value = Description } } ); Properties.ForEach(o => { List <Parameter> parameters = new List <Parameter>(); foreach (Property.Parameter p in o.Parameters) { parameters.Add(new Parameter() { Definition = PluginStorage.CreateObject <ParameterDefinition>(p.ClassName), Name = p.Name, Value = p.Value }); } config.AddProperty( PluginStorage.CreateObject <PropertyDefinition>(o.ClassName), parameters.ToArray() ); }); return(config); }
public void RunJob(JobRunModel model) { //Instanciate plugins depending on class name Job job = PluginStorage.CreateObject <Job>( //Go Fetch class name from config file JObject.Parse(File.ReadAllText("jobs\\" + model.Name + "\\config.json")).Value <string>("_class") ); //Load job from folder configuration job.LoadFromFolder("jobs", model.Name); //Create Logger list for the run LoggerList loggers = new LoggerList(); //Add Standard logger in the logger list loggers.AddLogger(new StandardLogger()); //Add job build in the process with his name as key and provide log _threadApplication.AddRun(model.Name, job, loggers); }
public sealed override void LoadFromFolder(string path, string folderName) { //Config.json object string configFile = File.ReadAllText(path + "\\" + folderName + "\\config.json"); JObject configFileObject = JObject.Parse(configFile); Name = folderName; Description = configFileObject.Value <string>("description"); JArray propConfigObjects = configFileObject .Value <JArray>("properties"); foreach (JToken propConfigObject in propConfigObjects) { Property prop = new Property() { Definition = PluginStorage.CreateObject <PropertyDefinition>(propConfigObject.Value <string>("_class")) }; foreach (JToken parameterConfigObject in propConfigObject.Value <JArray>("parameters")) { prop.Parameters.Add(new Parameter() { Definition = PluginStorage.CreateObject <ParameterDefinition>(parameterConfigObject.Value <string>("_class")), Name = parameterConfigObject.Value <string>("name"), Value = parameterConfigObject.Value <string>("value") }); } Properties.Add(prop); } JArray buildStepConfigObjects = configFileObject .Value <JArray>("buildSteps"); foreach (JToken buildStepConfigObject in buildStepConfigObjects) { BuildStep buildStep = new BuildStep() { Definition = PluginStorage.CreateObject <BuildStepDefinition>(buildStepConfigObject.Value <string>("_class")) }; foreach (JToken parameterConfigObject in buildStepConfigObject.Value <JArray>("parameters")) { buildStep.Parameters.Add(new Parameter() { Definition = PluginStorage.CreateObject <ParameterDefinition>(parameterConfigObject.Value <string>("_class")), Name = parameterConfigObject.Value <string>("name"), Value = parameterConfigObject.Value <string>("value") }); } BuildSteps.Add(buildStep); } Properties.Add(new Property() { Definition = new DescriptionPropertyDefinition.DescriptionPropertyDefinition(), Parameters = new List <Parameter>() { new Parameter() { Definition = new StringParameterDefinition.StringParameterDefinition(), Name = "name", Value = this.Name }, new Parameter() { Definition = new StringParameterDefinition.StringParameterDefinition(), Name = "description", Value = this.Description } } }); }