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

Post build step not removed from generated Maven job

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • job-dsl-plugin
    • None
    • core 1.609.3
      job-dsl-plugin 1.38
      maven-plugin 2.12

      Removing postBuildSteps block from a job-dsl script does not remove the post build step on the generated job. To reproduce, create a job-dsl seed job with this script:

      mavenJob('example') {
        goals 'clean install'
        postBuildSteps { maven { goals "sonar:sonar -Psonar" } }
      }
      

      Remove postBuildSteps block and run job-dsl seed job again. Configuration page of generated job example will still contain the post build step.

      On disk config.xml of generated job doesn't have <postbuilders/> section anymore. Reloading generated job using a groovy script in system console doesn't help. Only restarting Jenkins works. That makes me think that the bug is in Maven plugin but not in JobDSL plugin. Something is wrong when reloading config.xml of generated job.

          [JENKINS-30548] Post build step not removed from generated Maven job

          As I mentioned in JENKINS-26825, this is caused by another issue, JENKINS-21017. The Job DSL plugin, the CLI and the REST API all use a similar API and the problem exists for all those components and needs to be fixed in Jenkins core or the xstream library.

          Daniel Spilker added a comment - As I mentioned in JENKINS-26825 , this is caused by another issue, JENKINS-21017 . The Job DSL plugin, the CLI and the REST API all use a similar API and the problem exists for all those components and needs to be fixed in Jenkins core or the xstream library.

          Daniel Beck added a comment -

          Could Job DSL work around this particular issue by always generating an empty postBuildSteps container element? It's only a major issue if you cannot find an "empty value" (e.g. no custom workspace value is equivalent to the default workspace), otherwise is mostly just annoying.

          Daniel Beck added a comment - Could Job DSL work around this particular issue by always generating an empty postBuildSteps container element? It's only a major issue if you cannot find an "empty value" (e.g. no custom workspace value is equivalent to the default workspace), otherwise is mostly just annoying.

          Yoann Dubreuil added a comment - - edited

          Thanks danielbeck ! Putting an empty postBuildSteps block instead of removing it works around the issue.

          Yoann Dubreuil added a comment - - edited Thanks danielbeck ! Putting an empty postBuildSteps block instead of removing it works around the issue.

          Daniel Beck added a comment -

          I meant that Job DSL could do this automagically for the usual top-level elements in a config.xml, but I'm glad it inspired a workaround!

          Daniel Beck added a comment - I meant that Job DSL could do this automagically for the usual top-level elements in a config.xml, but I'm glad it inspired a workaround!

          Unlike what I said before, I can't make the workaround work. I think I mis-tested it on first step. A proper fix for JENKINS-21017 is needed here.

          Yoann Dubreuil added a comment - Unlike what I said before, I can't make the workaround work. I think I mis-tested it on first step. A proper fix for JENKINS-21017 is needed here.

          I found another workaround which seems to work all time. Instead of using a empty postBuildSteps, you can force Job DSL to generate the empty XML node with

           configure { it / 'postbuilders' } 

          Not really nice, but it works!

          Yoann Dubreuil added a comment - I found another workaround which seems to work all time. Instead of using a empty postBuildSteps , you can force Job DSL to generate the empty XML node with configure { it / 'postbuilders' } Not really nice, but it works!

          Jesse Glick added a comment -

          Verified duplicate of JENKINS-21017.

          Jesse Glick added a comment - Verified duplicate of JENKINS-21017 .

            daspilker Daniel Spilker
            ydubreuil Yoann Dubreuil
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: