Well, Job DSL is actually Groovy code. So something like the following
should work:
scm {
if(data.git_url) {
git {
remote {
url(data.git_url)
credentials('xxxxx-xxxx')
}
createTag(false)
}
}
else if(data.svn-url) {
svn(data.svn-url) {
it / locations / 'hudson.scm.SubversionSCM_-ModuleLocation' /
credentialsId << 'xxxxx-xxxx'
}
}
else {
// crash the build or something if none was found?
}
Cheers
2015-10-06 9:09 GMT+02:00 Nick Stolwijk <[email protected]>:
> I'm trying to rebuild my Jenkins jobs through the Job DSL. I have found a
> lot of documentation and examples, but none about conditional configuration.
>
> I have the following job input:
>
> projects {
> componentA {
> svn-url = 'https://svn.localhost/componenta/trunk/'
> }
> componentB {
> git-url = 'https://git.localhost/componentb.git'
> }
> }
>
> Now I am trying to create jobs for this:
>
> def createUT(name, data) {
> mavenJob("${name}_UT") {
> description("Generated. Don't edit!")
> scm {
> // git {
> // remote {
> // url(data.git_url)
> // credentials('xxxxx-xxxx')
> // }
> // createTag(false)
> // }
> svn(data.svn-url) {
> it / locations / 'hudson.scm.SubversionSCM_-ModuleLocation' /
> credentialsId << 'xxxxx-xxxx'
> }
> }
>
> How can I create the git or the svn part, based on which variable is
> declared?
>
> Hope someone can help.
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CAA9S6i4Df6ENZ55Qmqx7aUYGmNFexFJ3opmeeJC72dxQpf5AFA%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAA9S6i4Df6ENZ55Qmqx7aUYGmNFexFJ3opmeeJC72dxQpf5AFA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS7D%2BaczXQOSqJi44irrrXsR3JPoj7VQFnyHBJ2wMRq8tA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.