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

postbuildscript doesnt work with job-dsl plugin after upgrading to 3.0.0

    • job-dsl-plugin 1.81

      After the upgrade my build breaks with a cryptic NullPointerException error:

       

      [PostBuildScript] - [INFO] Executing post build scripts.
      ERROR: Build step failed with exception
      java.lang.NullPointerException
      at org.jenkinsci.plugins.postbuildscript.processor.Processor.processScriptFiles(Processor.java:110)
      at org.jenkinsci.plugins.postbuildscript.processor.Processor.processScripts(Processor.java:89)
      at org.jenkinsci.plugins.postbuildscript.processor.Processor.process(Processor.java:79)
      at org.jenkinsci.plugins.postbuildscript.processor.Processor.process(Processor.java:73)
      at org.jenkinsci.plugins.postbuildscript.PostBuildScript.perform(PostBuildScript.java:77)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
      at hudson.model.Build$BuildExecution.post2(Build.java:177)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
      at hudson.model.Run.execute(Run.java:1932)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:429)
      Build step 'Execute scripts' marked build as failure
      An attempt to send an e-mail to empty list of recipients, ignored.
      Notifying upstream projects of job completion
      Finished: FAILURE

       


       

      All I did was to upgrade the postbuildscript plugin only. My Job DSL configuration did not change at all:

       

      job.with {
      publishers {
      postBuildScripts {
      steps {
      shell(""" 

      echo 'Hello world'

      """.stripIndent())
      }
      onlyIfBuildSucceeds(false)
      }
      }
      }

       

      In the version 2.11.0, this Job DSL config produced the job output in image "correct-job-output.png", in 3.0.0 it produces the job output in image "broken-job-output.png".

       

          [JENKINS-66189] postbuildscript doesnt work with job-dsl plugin after upgrading to 3.0.0

          Daniel Heid added a comment -

          Hi denar50! Thanks for creating a ticket and reporting this issue. I will work on it as soon as I can.

          Daniel Heid added a comment - Hi denar50 ! Thanks for creating a ticket and reporting this issue. I will work on it as soon as I can.

          Daniel Heid added a comment -

          denar50 Could you please provide the generated config.xml file?

          Daniel Heid added a comment - denar50 Could you please provide the generated config.xml file?

          Edgar added a comment -

          I uploaded the generated config.xml of the job that uses the plugin dheid

          Edgar added a comment - I uploaded the generated config.xml of the job that uses the plugin dheid

          Daniel Heid added a comment -

          Hi denar50! I analysed the problem and found out, that the Job DSL plugin creates an outdated configuration that is no longer supported by the PostBuildScript plugin. Please change your Job DSL script and use the Dynamic DSL syntax as described here: https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL

          You can find the Dynamic DSL configuration examples in the API viewer: http://your-jenkins-url/jenkins/plugin/job-dsl/api-viewer/index.html#path/freeStyleJob-publishers-postBuildScript

          Example (I don't know if this works):

          postBuildScript {
              buildSteps {
                  postBuildStep {
                      results(Iterable<String> value)
                      buildSteps {
                          shell {
                              command("""#!/usr/bin/env bash
          xport DOCKER_USER=`id -u`
          export DOCKER_CLIENT_TIMEOUT=400
          export COMPOSE_HTTP_TIMEOUT=400
          docker-compose -f se/subsystem-tests.yml stop
          export DOCKER_CLIENT_TIMEOUT=400
          export COMPOSE_HTTP_TIMEOUT=400
          docker-compose -f se/subsystem-tests.yml rm -f
          rm -rf ${PWD}/se/tmp/mandateResponses
          """)
                          }
                      }
                  }
              }
              markBuildUnstable(false)
          }
          

          Hope this will fix your problem. Since there is nothing to do for me here, I close this ticket.

          Daniel Heid added a comment - Hi denar50 ! I analysed the problem and found out, that the Job DSL plugin creates an outdated configuration that is no longer supported by the PostBuildScript plugin. Please change your Job DSL script and use the Dynamic DSL syntax as described here: https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL You can find the Dynamic DSL configuration examples in the API viewer: http://your-jenkins-url/jenkins/plugin/job-dsl/api-viewer/index.html#path/freeStyleJob-publishers-postBuildScript Example (I don't know if this works): postBuildScript { buildSteps { postBuildStep { results(Iterable< String > value) buildSteps { shell { command("""#!/usr/bin/env bash xport DOCKER_USER=`id -u` export DOCKER_CLIENT_TIMEOUT=400 export COMPOSE_HTTP_TIMEOUT=400 docker-compose -f se/subsystem-tests.yml stop export DOCKER_CLIENT_TIMEOUT=400 export COMPOSE_HTTP_TIMEOUT=400 docker-compose -f se/subsystem-tests.yml rm -f rm -rf ${PWD}/se/tmp/mandateResponses """) } } } } markBuildUnstable( false ) } Hope this will fix your problem. Since there is nothing to do for me here, I close this ticket.

            dheid Daniel Heid
            denar50 Edgar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: