Search in sources :

Example 1 with JenkinsJobTemplateBuilder

use of org.fakekoji.jobmanager.JenkinsJobTemplateBuilder in project jenkins-scm-koji-plugin by judovana.

the class BuildJob method generateTemplate.

@Override
public String generateTemplate() throws IOException {
    // TODO: do this better
    final Map<TaskVariant, TaskVariantValue> variants = new HashMap<TaskVariant, TaskVariantValue>() {

        {
            putAll(getVariants());
            put(new TaskVariant("buildPlatform", "", Task.Type.BUILD, "", 0, Collections.emptyMap(), false), new TaskVariantValue(getPlatform().getId(), ""));
        }
    };
    return XML_DECLARATION + new JenkinsJobTemplateBuilder(JenkinsJobTemplateBuilder.loadTemplate(TASK_JOB_TEMPLATE), this).buildBuildProvidersTemplate(getBuildProviders()).buildFakeKojiXmlRpcApiTemplate(getProjectName(), variants, JenkinsJobTemplateBuilder.fillBuildPlatform(getPlatform(), getTask().getFileRequirements()), false).buildTriggerTemplate(getTask().getScmPollSchedule()).buildScriptTemplate(getTask(), getPlatformProvider(), getPlatform(), getScriptsRoot(), getExportedVariables()).buildPostBuildTasks(getTask().getXmlTemplate()).prettyPrint();
}
Also used : JenkinsJobTemplateBuilder(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder) HashMap(java.util.HashMap) TaskVariantValue(org.fakekoji.model.TaskVariantValue) TaskVariant(org.fakekoji.model.TaskVariant)

Example 2 with JenkinsJobTemplateBuilder

use of org.fakekoji.jobmanager.JenkinsJobTemplateBuilder in project jenkins-scm-koji-plugin by judovana.

the class TestJob method generateKojiTemplate.

private String generateKojiTemplate() throws IOException {
    final List<String> subpackageBlacklist;
    final List<String> subpackageWhitelist;
    if (getTask().getFileRequirements().getBinary().equals(Task.BinaryRequirements.BINARIES)) {
        // this is workaround
        // only one task is known to require binaries, and that requires them all
        // if ever listing will need filtering also on BINARIES
        // BINARIES and BINARIES_ALL mayb need to be introduced
        subpackageBlacklist = Arrays.asList();
        subpackageWhitelist = Arrays.asList(".*");
    } else {
        subpackageBlacklist = Stream.of(projectSubpackageBlacklist, getTask().getRpmLimitation().getBlacklist(), getBuildVariants().values().stream().map(TaskVariantValue::getSubpackageBlacklist).map(list -> list.orElse(Collections.emptyList())).flatMap(List::stream).collect(Collectors.toList())).flatMap(List::stream).distinct().collect(Collectors.toList());
        subpackageWhitelist = Stream.of(projectSubpackageWhitelist, getTask().getRpmLimitation().getWhitelist(), getBuildVariants().values().stream().map(TaskVariantValue::getSubpackageWhitelist).map(list -> list.orElse(Collections.emptyList())).flatMap(List::stream).collect(Collectors.toList())).flatMap(List::stream).distinct().collect(Collectors.toList());
    }
    return XML_DECLARATION + new JenkinsJobTemplateBuilder(loadTemplate(TASK_JOB_TEMPLATE), this).buildBuildProvidersTemplate(getBuildProviders()).buildKojiXmlRpcApiTemplate(getProduct().getPackageName(), getBuildPlatform(), getTask().getFileRequirements(), subpackageBlacklist, subpackageWhitelist).buildScriptTemplate(getTask(), getPlatformProvider(), getPlatform(), getScriptsRoot(), getExportedVariables()).buildTriggerTemplate(getTask().getScmPollSchedule()).buildPostBuildTasks(getTask().getXmlTemplate()).prettyPrint();
}
Also used : Arrays(java.util.Arrays) TASK_JOB_TEMPLATE(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.JenkinsTemplate.TASK_JOB_TEMPLATE) Platform(org.fakekoji.model.Platform) Task(org.fakekoji.model.Task) JenkinsJobTemplateBuilder.loadTemplate(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.loadTemplate) OToolVariable(org.fakekoji.model.OToolVariable) ArrayList(java.util.ArrayList) Map(java.util.Map) XML_DECLARATION(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.XML_DECLARATION) RELEASE_SUFFIX_VAR(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.RELEASE_SUFFIX_VAR) JenkinsJobTemplateBuilder(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) BuildProvider(org.fakekoji.model.BuildProvider) TaskVariantValue(org.fakekoji.model.TaskVariantValue) File(java.io.File) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) JenkinsJobTemplateBuilder.fillBuildPlatform(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.fillBuildPlatform) TaskVariant(org.fakekoji.model.TaskVariant) JDKVersion(org.fakekoji.model.JDKVersion) Comparator(java.util.Comparator) Collections(java.util.Collections) JenkinsJobTemplateBuilder(org.fakekoji.jobmanager.JenkinsJobTemplateBuilder) TaskVariantValue(org.fakekoji.model.TaskVariantValue) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

JenkinsJobTemplateBuilder (org.fakekoji.jobmanager.JenkinsJobTemplateBuilder)2 TaskVariant (org.fakekoji.model.TaskVariant)2 TaskVariantValue (org.fakekoji.model.TaskVariantValue)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 TASK_JOB_TEMPLATE (org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.JenkinsTemplate.TASK_JOB_TEMPLATE)1 RELEASE_SUFFIX_VAR (org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.RELEASE_SUFFIX_VAR)1 XML_DECLARATION (org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.XML_DECLARATION)1 JenkinsJobTemplateBuilder.fillBuildPlatform (org.fakekoji.jobmanager.JenkinsJobTemplateBuilder.fillBuildPlatform)1