TruckerCat
TruckerCat

Reputation: 1487

Jenkins NextGeneration Warnings plugin: publishIssues fails with there's no @DataBoundConstructor

Hi I am using a Jenkins pipeline file and i want to integrate the cpd tool. Therefore I am using the NextGenerationWarnings Plugin and followed their docs (See section Advanced Pipeline configuration).

For testing purpose I added the call to the checkout stage.

Stage:

stage ("Checkout") {
            cleanWs()
            echo "Using branch $BRANCH_NAME"
            def gitResult = checkout(scm)
            echo "${gitResult}"
            def myworkspace = pwd()
            sh "/var/lib/jenkins/pmd-bin-6.12.0/bin/run.sh cpd -failOnViolation false --minimum-tokens 70 --files $myworkspace/PROG --language cpp --format xml > cpd.xml"
            def cpd = scanForIssues tool: cpd(pattern: 'cpd.xml')
            unzip publishIssues {issues: [cpd]}
        }

Error:

During Build I receive the following error message.

[Pipeline] publishIssues

[Pipeline] }

[Pipeline] // stage

[Pipeline] echo

ERROR: java.lang.IllegalArgumentException: Could not instantiate {issues=org.jenkinsci.plugins.workflow.cps.CpsClosure2@2c319167} for PublishIssuesStep(issues: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class io.jenkins.plugins.analysis.core.steps.AnnotatedReport[], failedNewAll?(deprecated): int, failedNewHigh?(deprecated): int, failedNewLow?(deprecated): int, failedNewNormal?(deprecated): int, failedTotalAll?(deprecated): int, failedTotalHigh?(deprecated): int, failedTotalLow?(deprecated): int, failedTotalNormal?(deprecated): int, healthy?: int, id?: String, ignoreFailedBuilds?: boolean, ignoreQualityGate?: boolean, minimumSeverity?: String, name?: String, qualityGates?: QualityGate(threshold: int, type: QualityGateType[TOTAL, TOTAL_ERROR, TOTAL_HIGH, TOTAL_NORMAL, TOTAL_LOW, NEW, NEW_ERROR, NEW_HIGH, NEW_NORMAL, NEW_LOW, DELTA, DELTA_ERROR, DELTA_HIGH, DELTA_NORMAL, DELTA_LOW], unstable: boolean)[], referenceJobName?: String, sourceCodeEncoding?: String, unhealthy?: int, unstableNewAll?(deprecated): int, unstableNewHigh?(deprecated): int, unstableNewLow?(deprecated): int, unstableNewNormal?(deprecated): int, unstableTotalAll?(deprecated): int, unstableTotalHigh?(deprecated): int, unstableTotalLow?(deprecated): int, unstableTotalNormal?(deprecated): int): java.lang.ClassCastException: io.jenkins.plugins.analysis.core.steps.PublishIssuesStep.issues expects java.util.List but received class org.jenkinsci.plugins.workflow.cps.CpsClosure2

I am not sure what the @DataBoundConstructor annotation does, but could that be related to an outdated java version?

Upvotes: 0

Views: 2075

Answers (1)

TruckerCat
TruckerCat

Reputation: 1487

I found my problem.

I dont know why, but for some reason I added unzip and these {} around publishIssues issues: [cpd].

Removing them, resolved my issue and now it works perfect.

Upvotes: 2

Related Questions