Hey!

I'm trying to set up a builder pattern that allows other developers in my 
team to easily set up pipeline jobs without having to know the exact groovy 
syntax for their jobs.
First, to clarify what I mean, I want to quickly show you how we used that 
for our freestyle jobs:

protected final Job job

FreeStyleJobBuilder(final DslFactory dslFactory, final String jobName) {
    this.job = dslFactory.job(jobName)
}


After setting the Job object we could keep adding functions to it, for 
example:

FreeStyleJobBuilder addPreBuildCleanup() {
    job.wrappers { preBuildCleanup() }
    this
}

FreeStyleJobBuilder addHtmlReport(String htmlDirectory, String htmlFiles, 
String htmlReportName) {
    job.publishers {
        publishHtml {
            report(htmlDirectory) {
                reportFiles htmlFiles
                reportName htmlReportName
                keepAll()
                alwaysLinkToLastBuild()
            }
        }
    }
    this
}


That way each developer/tester could easily set up their own job:

new FreeStyleJobBuilder(dslFactory, *jobName*)
        .setDescription("description...")
        .setLogRotator(365, 50, 365, 10)
        .addPreBuildCleanup()
        .setSlaveLabel(Executor.SMOKE)
        .addUpstreamProjectTrigger("../TestTrigger-Smoke")
        .addArtifactsToCopy("../../Build_Tester")



Now, I'm trying to set up a similar way for pipeline jobs that would enable 
building custom pipeline jobs with custom stages.
I know I can use "dslFactory.pipelineJob(jobName)" to get some of the 
pipeline features but its scope seems pretty limited and focuses on getting 
the pipeline script either as a script or path. I'd especially like to get 
the nice features from declarative pipelines while avoiding using a 
harcoded pipeline script.

Does anyone have any suggestions how to approach this problem?

Thanks!
Sharon


pipelineJob API: 
https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.DslFactory.pipelineJob
  
<https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.DslFactory.pipelineJob>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b5e2f044-f2b3-4289-a193-4424d24eb7df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to