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

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

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • job-dsl-plugin
    • Jenkins ver. 1.658
      Job-DSL ver. 1.48
      Slack Notification Plugin 2.0.1

      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.

          [JENKINS-37991] jenkins-dsl-plugin gradle test fails when using new slackNotifier syntax

          C WS created issue -
          C WS made changes -
          Description Original: 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.
          New: 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.

          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

          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
          C WS made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

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

          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

          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.

          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.

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

              Created:
              Updated:
              Resolved: