Hi all,

I'm trying to avoid duplication in my jobDSL configuration by extracting
base functionality.

It seems I'm failing. ;-)

static void basicJob(def jobName, def buildName, def jdk,
@DslContext(FreeStyleJob) Closure closure)
FreeStyleJob job = freeStyleJob(jobName) {
description("Generated by a JobDSL. Do NOT edit manually!")
label('Slave_Buildserver1')
compressBuildLog()
wrappers {
preBuildCleanup()
maskPasswords()
buildName(buildName)
timeout {
absolute(180)
}
}
                if(jdk) {
jdk(jdk)
                   } else {
   jdk("JDK 8 64bits")
        }
};
ContextHelper.executeInContext(closure, job)
}

        basicJob("${componentName}/${reponame}/finishrelease",
'#${BUILD_NUMBER} release ${releaseVersion}', data.jdk) {
steps {
maven {
mavenInstallation("Apache Maven 3.3.x")
goals('--batch-mode clean verify')
}
        }

(I've simplified the above code somewhat)

But I get the following error: workspace:/utilities/BasicUtilities.groovy:
26: unexpected token: ContextHelper @ line 26, column 3.
ContextHelper.executeInContext(closure,
job)

Are there any good blogs about refactoring DSL code?
What am I doing wrong?

With regards,

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when
your turn comes to die, you can die happy in feeling that at any rate you
have not wasted your time but have done your best ~~~

Lord Baden-Powell

-- 
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/CAA9S6i6YKZomV2nJR5FssXdz%3DrsaNArQ-hFjqMwmKpv_RuqhAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to