Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40432

writeMavenPom throws class cast exception when creating a new pom file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • Jenkins 2.36, Pipeline 2.4, Pipeline Utility Steps 1.2.1
      Oracle Java 1.8.0_40

      Creation of a pom file from a pipeline

      node ('master') {
          Model pom = new Model()
          pom.artifactId = 'my-test-project'
          pom.groupId = 'com.example.jenkins.test'
          pom.version = '1.1-SNAPSHOT'
          writeMavenPom(pom)
      }
      

      using writeMavenPom fails with:

      [Pipeline] End of Pipeline
      java.lang.ClassCastException: org.jenkinsci.plugins.pipeline.utility.steps.maven.WriteMavenPomStep.model expects class org.apache.maven.model.Model but received class org.apache.maven.model.Model
      

      However, reading and existing pom, making modifications and writing those to a file works like a charm.
      Test case for writeMavenPom (https://github.com/jenkinsci/pipeline-utility-steps-plugin/blob/master/src/test/java/org/jenkinsci/plugins/pipeline/utility/steps/maven/WriteMavenPomStepTest.java) passes, but it is using an older version of pipeline dependencies.

            rsandell rsandell
            janis_b Janis Balodis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: