How to publish Codenarc report for Gradle project in Jenkins

If you are trying to generate Codenarc reports for Gradle Groovy project and publish them in Jenkins then you would require the following configuration:

build.gradle

apply plugin: 'codenarc'
...
dependencies {
    codenarc 'org.codenarc:CodeNarc:0.21'
    ...
}
codenarc {
    configFile = file('config/codenarc/codenarc.groovy')
    // sourceSets = [project.sourceSets.main] // run codenarc on production sources only
    ignoreFailures = true // Let the build finish even though there are code warnings
    reportFormat = 'xml'
    reportsDir = new File("build/reports/codenarc")
}

config/codenarc/codenarc.groovy

// Read and choose rules here: http://codenarc.sourceforge.net/codenarc-rule-index.html 
ruleset {
    ruleset('rulesets/basic.xml')
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s