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

jenkins-dsl-plugin gradle test fails when using new slackNotifier syntax

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Won't Fix
    • Component/s: job-dsl-plugin
    • Labels:
    • Environment:
      Jenkins ver. 1.658
      Job-DSL ver. 1.48
      Slack Notification Plugin 2.0.1
    • Similar Issues:

      Description

      I have a seed job definition which is failing gradle test even though it seems to work fine when we use it in Jenkins.

      //package master
      // GitURL
      def gitUrl = 'https://github.com/team/myapp'
      def slackRoom = null
      
      job('seed-dsl') {
          description('This seed is updated from the seed-dsl-updater job')
          properties {
              //Set github project URL
              githubProjectUrl(gitUrl)
          }
          ...
          // publishers is another name for post build steps
          publishers {
              mailer('', false, true)
              slackNotifier {
                  room(slackRoom)
                  notifyAborted(true)
                  notifyFailure(true)
                  notifyNotBuilt(true)
                  notifyUnstable(true)
                  notifyBackToNormal(true)
                  notifySuccess(false)
                  notifyRepeatedFailure(false)
                  startNotification(false)
                  includeTestSummary(false)
                  includeCustomMessage(false)
                  customMessage(null)
                  buildServerUrl(null)
                  sendAs(null)
                  commitInfoChoice('NONE')
                  teamDomain(null)
                  authToken(null)
              }
          }
      }
      

      The gradle test command works fine when I comment out the with the slackNotifier declaration, but fail with the following error when it's enabled:

      test fail excerpt
      Caused by:
              javaposse.jobdsl.dsl.DslScriptException: (script, line 79) No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.slackNotifier() is applicable for argument types: (script$_run_closure1$_closure9$_closure14) values: [script$_run_closure1$_closure9$_closure14@d2392a1]
              Possible solutions: stashNotifier(), stashNotifier(groovy.lang.Closure)
                  at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:135)
                  at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader_closure1(DslScriptLoader.groovy:78)
      

      full output

      According to the migration doc, slackNotifer has been supported since 1.47. In my gradle.build, I'm using 1.48. I see the same errors with plugin version 1.50

      gradle.build
      ext {
       jobDslVersion = '1.48'
       ...
      }
      ...
      // Job DSL plugin including plugin dependencies
      testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
      testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
      ...
      

      The gradle.build also includes the following, as suggested by the testing docs.

      testPlugins 'org.jenkins-ci.plugins:slack:2.0.1'
      

      To reproduce:
      Download the seed job into the jobs directory, and run gradle test with the slackNotifier directive enabled. Comment out the slackNotifier directive and observe passing tests.

      Note: The job definition fails when ran on the DSL playground, as well.

        Attachments

          Activity

          cvvs C WS created issue -
          cvvs C WS made changes -
          Field Original Value New Value
          Description I have a [seed job definition|https://gist.github.com/cvvs/2451c9444e536b1c60fe9df7d1ea37b8] which is failing gradle test even though it seems to work fine when we use it in Jenkins.

          {code}
          //package master
          // GitURL
          def gitUrl = 'https://github.com/team/myapp'
          def slackRoom = null

          job('seed-dsl') {
              description('This seed is updated from the seed-dsl-updater job')
              properties {
                  //Set github project URL
                  githubProjectUrl(gitUrl)
              }
              ...
              // publishers is another name for post build steps
              publishers {
                  mailer('', false, true)
                  slackNotifier {
                      room(slackRoom)
                      notifyAborted(true)
                      notifyFailure(true)
                      notifyNotBuilt(true)
                      notifyUnstable(true)
                      notifyBackToNormal(true)
                      notifySuccess(false)
                      notifyRepeatedFailure(false)
                      startNotification(false)
                      includeTestSummary(false)
                      includeCustomMessage(false)
                      customMessage(null)
                      buildServerUrl(null)
                      sendAs(null)
                      commitInfoChoice('NONE')
                      teamDomain(null)
                      authToken(null)
                  }
              }
          }
          {code}

          The gradle test command works fine when I comment out the with the slackNotifier declaration, but fail with the following error when it's enabled:

          {code:title=test fail excerpt}
          Caused by:
                  javaposse.jobdsl.dsl.DslScriptException: (script, line 79) No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.slackNotifier() is applicable for argument types: (script$_run_closure1$_closure9$_closure14) values: [script$_run_closure1$_closure9$_closure14@d2392a1]
                  Possible solutions: stashNotifier(), stashNotifier(groovy.lang.Closure)
                      at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:135)
                      at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader_closure1(DslScriptLoader.groovy:78)
          {code}
          [full output|https://gist.github.com/cvvs/dd63b0ea4266f19657081c6770ca3388]

          According to the [migration doc|https://github.com/jenkinsci/job-dsl-plugin/blob/master/docs/Migration.md#slack], slackNotifer has been supported since 1.47. In my [gradle.build|https://gist.github.com/cvvs/c5dfd8cc27a2a0b7f017bc21405c980e], I'm using 1.48. I see the same errors with plugin version 1.50
          {code:title=gradle.build}
          ext {
           jobDslVersion = '1.48'
           ...
          }
          ...
          // Job DSL plugin including plugin dependencies
          testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
          testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
          ...
          {code}

          The gradle.build also includes the following, as suggested by the [testing docs|https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts].
          {code}
          testPlugins 'org.jenkins-ci.plugins:slack:2.0.1'
          {code}

          To reproduce:
          Download the seed job into the jobs directory, and run gradle test with the slackNotifier directive enabled. Comment out the slackNotifier directive and observe passing tests.
          I have a [seed job definition|https://gist.github.com/cvvs/2451c9444e536b1c60fe9df7d1ea37b8] which is failing gradle test even though it seems to work fine when we use it in Jenkins.

          {code}
          //package master
          // GitURL
          def gitUrl = 'https://github.com/team/myapp'
          def slackRoom = null

          job('seed-dsl') {
              description('This seed is updated from the seed-dsl-updater job')
              properties {
                  //Set github project URL
                  githubProjectUrl(gitUrl)
              }
              ...
              // publishers is another name for post build steps
              publishers {
                  mailer('', false, true)
                  slackNotifier {
                      room(slackRoom)
                      notifyAborted(true)
                      notifyFailure(true)
                      notifyNotBuilt(true)
                      notifyUnstable(true)
                      notifyBackToNormal(true)
                      notifySuccess(false)
                      notifyRepeatedFailure(false)
                      startNotification(false)
                      includeTestSummary(false)
                      includeCustomMessage(false)
                      customMessage(null)
                      buildServerUrl(null)
                      sendAs(null)
                      commitInfoChoice('NONE')
                      teamDomain(null)
                      authToken(null)
                  }
              }
          }
          {code}

          The gradle test command works fine when I comment out the with the slackNotifier declaration, but fail with the following error when it's enabled:

          {code:title=test fail excerpt}
          Caused by:
                  javaposse.jobdsl.dsl.DslScriptException: (script, line 79) No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.slackNotifier() is applicable for argument types: (script$_run_closure1$_closure9$_closure14) values: [script$_run_closure1$_closure9$_closure14@d2392a1]
                  Possible solutions: stashNotifier(), stashNotifier(groovy.lang.Closure)
                      at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:135)
                      at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader_closure1(DslScriptLoader.groovy:78)
          {code}
          [full output|https://gist.github.com/cvvs/dd63b0ea4266f19657081c6770ca3388]

          According to the [migration doc|https://github.com/jenkinsci/job-dsl-plugin/blob/master/docs/Migration.md#slack], slackNotifer has been supported since 1.47. In my [gradle.build|https://gist.github.com/cvvs/c5dfd8cc27a2a0b7f017bc21405c980e], I'm using 1.48. I see the same errors with plugin version 1.50
          {code:title=gradle.build}
          ext {
           jobDslVersion = '1.48'
           ...
          }
          ...
          // Job DSL plugin including plugin dependencies
          testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
          testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
          ...
          {code}

          The gradle.build also includes the following, as suggested by the [testing docs|https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts].
          {code}
          testPlugins 'org.jenkins-ci.plugins:slack:2.0.1'
          {code}

          To reproduce:
          Download the seed job into the jobs directory, and run gradle test with the slackNotifier directive enabled. Comment out the slackNotifier directive and observe passing tests.

          Note: The job definition fails when ran on the DSL playground, as well.
          Hide
          cvvs C WS added a comment -

          So after discussion with peers and digging through various wikis, we've come to the conclusion that Automatically Generated DSL isn't testable using gradlew? test

          Show
          cvvs C WS added a comment - So after discussion with peers and digging through various wikis, we've come to the conclusion that Automatically Generated DSL isn't testable using gradlew? test
          cvvs C WS made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Won't Fix [ 2 ]
          Hide
          daspilker Daniel Spilker added a comment -

          There is a wiki page about testing scripts with Automatically Generated DSL: https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts

          Show
          daspilker Daniel Spilker added a comment - There is a wiki page about testing scripts with Automatically Generated DSL: https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts
          Hide
          punnie Pedro Coelho added a comment -

          I have the exact same problem with both slackNotifier (plugin version 2.1) and ghprbTrigger (plugin version 1.33.1). Jenkins version is 2.33.

          I have been using the build script at https://github.com/sheehan/job-dsl-gradle-example which is an augmented version of the one you mention.

          Tests pass locally and it fail when running in Jenkins, in a seed job that executes the gradle steps as it does locally. Everything works in Jenkins when ignoring the tests.

          This did not happen two weeks earlier. I am unsure at this point what I've upgraded, but if you wish to revisit this bug I'll be happy to investigate.

          Show
          punnie Pedro Coelho added a comment - I have the exact same problem with both slackNotifier (plugin version 2.1) and ghprbTrigger (plugin version 1.33.1). Jenkins version is 2.33. I have been using the build script at https://github.com/sheehan/job-dsl-gradle-example which is an augmented version of the one you mention. Tests pass locally and it fail when running in Jenkins, in a seed job that executes the gradle steps as it does locally. Everything works in Jenkins when ignoring the tests. This did not happen two weeks earlier. I am unsure at this point what I've upgraded, but if you wish to revisit this bug I'll be happy to investigate.

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              cvvs C WS
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: