import jenkins.automation.builders.FlowJobBuilder

def flowJob = new FlowJobBuilder(
        name: 'GeneratedFlowJob',
        description: 'this is a simple build flow job',
        jobs:['job1', 'job2'],
        emails:['joe@example.com', 'jane@example.com']
).build(this);

flowJob.with{
    logRotator{
        numToKeep(365)
    }
}


def customFlowJob = new FlowJobBuilder(
        name: 'GeneratedCustomFlowJob',
        description: 'this a custom flow job',
        jobFlow: """
                build('job1')
                build('job2')
                parallel(
                 { build('job3') },
                 { build('job4') },
                )
            """
).build(this);

customFlowJob.with{
    logRotator{
        numToKeep(365)
    }
}

def customFlowJobWithWorkspace = new FlowJobBuilder(
        name: 'flow-job-with-workspace',
        description: 'a build flow job with its own workspace',
        jobs:['job1', 'job2']
).build(this)

customFlowJobWithWorkspace.with{
    scm {
        git('https://github.com/cfpb/qu.git', 'master')
    }

    configure { node ->
        node << buildNeedsWorkspace(true)
    }
}

import jenkins.automation.builders.FlowJobBuilder

def flowJob = new FlowJobBuilder(
        name: 'GeneratedFlowJob',
        description: 'this is a simple build flow job',
        jobs:['job1', 'job2'],
        emails:['joe@example.com', 'jane@example.com']
).build(this);

flowJob.with{
    logRotator{
        numToKeep(365)
    }
}


def customFlowJob = new FlowJobBuilder(
        name: 'GeneratedCustomFlowJob',
        description: 'this a custom flow job',
        jobFlow: """
                build('job1')
                build('job2')
                parallel(
                 { build('job3') },
                 { build('job4') },
                )
            """
).build(this);

customFlowJob.with{
    logRotator{
        numToKeep(365)
    }
}

def customFlowJobWithWorkspace = new FlowJobBuilder(
        name: 'flow-job-with-workspace',
        description: 'a build flow job with its own workspace',
        jobs:['job1', 'job2']
).build(this)

customFlowJobWithWorkspace.with{
    scm {
        git('https://github.com/cfpb/qu.git', 'master')
    }

    configure { node ->
        (node / buildNeedsWorkspace).value = true
    }
}

Update example build flow job to use a configure block for buildNeedsWorkspace that works with job-dsl 1.42, which now includes buildNeedsWorkspace; this new block is compatible with all versions of job-dsl, not just pre-1.42
Update example build flow job to use a configure block for buildNeedsWorkspace that works with job-dsl 1.42, which now includes buildNeedsWorkspace; this new block is compatible with all versions of job-dsl, not just pre-1.42
