0

I'm trying to enable the violations and the Checkstyle option only in my "Build Settings" section of my Jenkins job and below is the code snippet :

  publishers {
    violations(100)    
    checkstyle('') {
        }
    }

It works fine but the violations and checkstyle configurations gets generated on the "Post-Build Actions" section rather in "Build Settings" section.

I'm looking to configure my job like below : Expected Job configuration

but I'm getting the Job configuration like below:

enter image description here

Is it possible to just the enable the 'violations' and 'Publish CheckStyle Analysis Results' checkboxes on the "Build Settings" section of my Job ONLY.

Jenkins Version - 2.32.2

Job DSL - 1.57

violations plugin - 0.7.11

Checkstyle plugin - 3.47

P.S. I did a restart too after I installed the above plugins but the same problem.

Any advise pls. Thanks.

voltas
  • 553
  • 7
  • 24
  • My Jenkins installation does not have a "Build Settings" tab, so it's probably provided by a plugin. Do you know which plugin that is? – daspilker Feb 23 '17 at 20:52
  • @daspilker : You're right, it comes from the Maven Release plugin(https://wiki.jenkins-ci.org/display/JENKINS/M2+Release+Plugin) and the "Build Settings" tab is specific for Maven Jobs only. I'm not sure how to leverage the configure block for that plugin to achieve my reqyirement. Any inputs please.Thanks – voltas Feb 24 '17 at 09:47

1 Answers1

2

Support for the "Build Settings" section of the Maven job type is not built-in. You need to use a Configure Block:

mavenJob('example') {
  configure {
    it / reporters << 'hudson.plugins.violations.hudson.maven.ViolationsMavenReporter' {
      config {
        typeConfigs {
          entry {
            string('checkstyle')
            'hudson.plugins.violations.TypeConfig' {
              type('checkstyle')
              min(10)
              max(999)
              unstable(999)
              usePattern(false)
            }
          }
        }
      }
    }
  }
}
daspilker
  • 8,154
  • 1
  • 35
  • 49
  • Thanks a ton for your valuable insight, I leveraged it for e-mail as well as checkstyle configuration too. Now I realise the power of Configure Block. Thanks again – voltas Feb 25 '17 at 00:56