import models.*
import templates.*
import hudson.FilePath
import org.yaml.snakeyaml.Yaml
createJobs()
void createJobs() {
def yaml = new Yaml()
// Build a list of all config files ending in .yml
def cwd = hudson.model.Executor.currentExecutor().getCurrentWorkspace().absolutize()
def configFiles = new FilePath(cwd, 'ci-repos').list('*.yml')
// Create a Build job for each config file
configFiles.each { file ->
def projectConfig = yaml.loadAs(file.readToString(), ProjectConfig.class)
def project = projectConfig.project.replaceAll(' ', '-')
PrepareBuildPublish.create(job("${project}-Prepare-Build-Publish"), projectConfig)
}
}
here is my models.ProjectConfig class:
package models
/**
* Simple value object to store configuration information for a project.
*/
class ProjectConfig {
String project
String repo
String email
}
Here is the AjaxRecorder.yml:
project: AjaxRecorder
repo: Web/AjaxRecorder
email: my.address@company.com
When I run the main.groovy -> I get this error:
14:06:13 ERROR: Can't construct a java object for tag:yaml.org,2002:models.ProjectConfig; exception=Class not found: models.ProjectConfig
14:06:13 in 'string', line 1, column 1:
14:06:13 project: AjaxRecorder
Please help with this error. Any ideas?