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

Post build step not removed from generated Maven job

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • job-dsl-plugin
    • None
    • core 1.609.3
      job-dsl-plugin 1.38
      maven-plugin 2.12

    Description

      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.

      Attachments

        Issue Links

          Activity

            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.

            daspilker 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.
            danielbeck 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.

            danielbeck 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.
            ydubreuil Yoann Dubreuil added a comment - - edited

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

            ydubreuil Yoann Dubreuil added a comment - - edited Thanks danielbeck ! Putting an empty postBuildSteps block instead of removing it works around the issue.
            danielbeck 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!

            danielbeck 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.

            ydubreuil 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!

            ydubreuil 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!
            jglick Jesse Glick added a comment -

            Verified duplicate of JENKINS-21017.

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

            People

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

              Dates

                Created:
                Updated:
                Resolved: