[workflow-plugin] clean after checkout in GenericSCM step

166 views
Skip to first unread message

Timur Batyrshin

unread,
Feb 3, 2015, 6:32:23 AM2/3/15
to jenkins...@googlegroups.com
Hi all,


How should I clean the checkout directory using GenericSCM step of workflow-plugin?

The snippet generator generates the line like the following:
checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [<object of type hudson.plugins.git.extensions.impl.CleanCheckout>], userRemoteConfigs: [[credentialsId: '4db1f14a-c479-48af-a3ea-da676bc2b051', url: 'https://github.com/XXXXXX/XXXXXXXXXX.git']]]

It looks like the [<object of type hudson.plugins.git.extensions.impl.CleanCheckout>] is not the correct Groovy syntax here (so says Jenkins).

I've tried passing the following ways of specifying extensions but none of them worked:

extensions: [hudson.plugins.git.extensions.impl.CleanCheckout()]
extensions: [CleanCheckout()]  // + at the very top of the script "import hudson.plugins.git.extensions.impl.CleanCheckout"
extensions: [$class: 'CleanCheckout']
extensions: [[$class: 'CleanCheckout']]

Any ideas how this should be done?


Thanks,
Timur

Scott Armit

unread,
Feb 18, 2015, 4:22:12 PM2/18/15
to jenkins...@googlegroups.com
I've been hitting this as well. That doesn't help you solve it, however. I'm starting to think Workflow Plugin 1.1 is not ready for prime time. I hit a lot of bogus items.

Clifford Sanders

unread,
Feb 19, 2015, 9:03:51 AM2/19/15
to jenkins...@googlegroups.com
Hi Timur,

I had a similar problem with cloning into another directory. If you look into the config.xml of a job where the GitSCM is used you see something like this:

  <scm class="hudson.plugins.git.GitSCM" plugin="g...@2.3.4">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>*/master</name>
      </hudson.plugins.git.BranchSpec>
    </branches>
    <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
    <submoduleCfg class="list"/>
    <extensions>
      <hudson.plugins.git.extensions.impl.CleanCheckout/>
    </extensions>
  </scm>

the extension part must be 'translated' to:

extensions: [[$class: 'hudson.plugins.git.extensions.impl.CleanCheckout']]

So you command should be something like:

checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: extensions: [[$class: 'hudson.plugins.git.extensions.impl.CleanCheckout']], userRemoteConfigs: [[credentialsId: '4db1f14a-c479-48af-a3ea-da676bc2b051', url: 'https://github.com/XXXXXX/XXXXXXXXXX.git']]]

Regards

Clifford

Jesse Glick

unread,
Feb 26, 2015, 11:51:31 AM2/26/15
to jenkins...@googlegroups.com
On Thursday, February 19, 2015 at 9:03:51 AM UTC-5, Clifford Sanders wrote:
extensions: [[$class: 'hudson.plugins.git.extensions.impl.CleanCheckout']]

Actually just $class: 'CleanCheckout' should suffice.

Reply all
Reply to author
Forward
0 new messages