You need to configure in “job” block not “git” block like :

job(‘job’) {
  scm {
    git {
     …
    } //git
  } //scm

  configure { project ->
                project / scm(class: ‘hudson.plugins.git.GitSCM’) {
                                gitTool ‘Ubuntu Git’
                } //project
} //configure
} //job


From: <jenkinsci-users@googlegroups.com> on behalf of shaneoh1980 McP 
<shane.dobson1...@gmail.com>
Reply-To: "jenkinsci-users@googlegroups.com" <jenkinsci-users@googlegroups.com>
Date: Thursday, January 5, 2017 at 8:16 AM
To: Jenkins Users <jenkinsci-users@googlegroups.com>
Subject: Cannot set Git executable using Job DSL

I'm converting all of our Jenkins jobs to DSL scripts and I've come accross one 
where we use a Git executable other than the "default" one.

I've spent two days trying to get this to work and no matter what I do it just 
won't work. I need this in the config.xml which gets generated for the job 
("Ubuntu Git" is the name of one of our Git installations which is configured 
as a tool for the Jenkins server):

<gitTool>Ubuntu Git</gitTool>

But no matter what I do I always end up with:

<gitTool>default</gitTool>

It doesn't seem to be supported by the DSL so I have been using the configure 
block. I've tried hundreds of ways but the way I most expected to work is 
below. Note that I am new to using the configure block. This is starting to 
drive me spare - does anyone know what is wrong in this configure block that I 
have? Or, am I somehow missing that this is actually natively supported by the 
job dsl?


job('job') {
  scm {
    git {
      remote {
        url('https://github.com/mygithub/project.git')
        credentials('25dwere85ds-dgh6-5874-6954-e226asdasd07e7')
        branches('*/my_branch')


       configure { project ->
         project << 'hudson.plugins.git.GitSCM' {
           paramDefs << 'gitTool' {
             string('Ubuntu Git')
               }
            }
         }
      }
   }
}


I would appreciate any advice.
--
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<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/d16271ae-207d-41a5-b926-2071a8ab9055%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/d16271ae-207d-41a5-b926-2071a8ab9055%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/3FF1AB07-7713-44F9-876B-47B724033990%40cisco.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to