This one works correctly (put configure block inside git block).

    scm {
        git {
            remote {
                ..
            }
             configure { node ->
                                node / gitTool << 'Ubuntu Git'
             }
         }
   …
    }

From: shaneoh1980 McP <[email protected]>
Date: Friday, January 6, 2017 at 2:35 AM
To: Jenkins Users <[email protected]>
Cc: "Indra Gunawan (ingunawa)" <[email protected]>
Subject: Re: Cannot set Git executable using Job DSL

I should add that if I create a job using this as a seed job, the default 
option is still selected.

On Friday, 6 January 2017 07:44:12 UTC, shaneoh1980 McP wrote:
Thanks - but that generates a separate block of XML, with what I want, but it 
doesn't apply it to the git scm and therefore has no effect on the job.  In 
other words, inside the XML for git, I still see:

<gitTool>Default</gitTool>


But then outside that, in a separate block, I see:

    <scm(class: ‘hudson.plugins.git.GitSCM’)>
        <gitTool>Ubuntu Git</gitTool>
    </scm(class: ‘hudson.plugins.git.GitSCM’)>
</project>




On Thursday, 5 January 2017 20:04:13 UTC, Indra Gunawan (ingunawa) wrote:
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: <[email protected]> on behalf of shaneoh1980 McP 
<[email protected]>
Reply-To: "[email protected]" <[email protected]>
Date: Thursday, January 5, 2017 at 8:16 AM
To: Jenkins Users <[email protected]>
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 [email protected].
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/98B43C14-D95A-4354-9401-DE03DEA9DDD3%40cisco.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to