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

Behavior enum isn't available in PublisherContext for Groovy PostBuild Plug-in

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • job-dsl-plugin
    • Job DSL 1.42 w/ Jenkins 1.609.1 in official Jenkins Docker Container

      When trying to add second Behavior parameter to groovyPostBuild("script here", Behavior.DoNothing) I got this error message:

      ERROR: (Script1.groovy, line 17) No such property: Behavior for class: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext

          [JENKINS-32520] Behavior enum isn't available in PublisherContext for Groovy PostBuild Plug-in

          I can't reproduce this. I tried the following script on the playground and it works fine:

          job('example') {
            publishers {
               groovyPostBuild("script here", Behavior.DoNothing)
            }
          }
          

          The implicit imports for enums only work in top-level scripts. If you are using helper classes, you need to add imports for any enums, e.g.:

          import javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.Behavior
          

          Daniel Spilker added a comment - I can't reproduce this. I tried the following script on the playground and it works fine: job( 'example' ) { publishers { groovyPostBuild( "script here" , Behavior.DoNothing) } } The implicit imports for enums only work in top-level scripts. If you are using helper classes, you need to add imports for any enums, e.g.: import javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.Behavior

          Chris Pauley added a comment -

          Yes, I was using a helper script and wasn't aware I needed to add that import, thanks for the insight! You can go ahead and close this ticket.

          Chris Pauley added a comment - Yes, I was using a helper script and wasn't aware I needed to add that import, thanks for the insight! You can go ahead and close this ticket.

            daspilker Daniel Spilker
            cmpauley Chris Pauley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: