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

GString not supported by automatically generated DSL

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • None

      The following script will cause an error because of the GString argument to room

      def SLACK_CHANNEL = 'bar'
      
      job('example') {
        publishers {
          slackNotifier {
            room("foo-${SLACK_CHANNEL}")
            notifyAborted(true)
            notifyFailure(true)
            notifyNotBuilt(false)
            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)
          }
        }
      }
      

      console log:

      Processing provided DSL script
      ERROR: (script, line 6) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.room() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [foo-bar]
      Possible solutions: wait(), dump(), any(), find(), grep(), wait(long)
      Finished: FAILURE
      

          [JENKINS-39153] GString not supported by automatically generated DSL

          Rachel M. added a comment -

          It works in this way:

          def SLACK_CHANNEL = 'bar'
          
          job('example') {
            publishers {
              slackNotifier {
                room('foo-' + "${SLACK_CHANNEL}")
                notifyAborted(true)
                notifyFailure(true)
                notifyNotBuilt(false)
                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)
              }
            }
          }
          

          Rachel M. added a comment - It works in this way: def SLACK_CHANNEL = 'bar' job( 'example' ) { publishers { slackNotifier { room( 'foo-' + "${SLACK_CHANNEL}" ) notifyAborted( true ) notifyFailure( true ) notifyNotBuilt( false ) 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 ) } } }

          This is still an issue, but a minor one since there is an easy workaround.

          Daniel Spilker added a comment - This is still an issue, but a minor one since there is an easy workaround.

          Rachel M. added a comment -

          Oh, sorry deeply daspilker, I've just seen you maintain the Job DSL Plugin and I thought it was a user's problem.

          Rachel M. added a comment - Oh, sorry deeply daspilker , I've just seen you maintain the Job DSL Plugin and I thought it was a user's problem.

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          docs/Home.md
          job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/structs/DescribableContext.groovy
          job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/ExecuteDslScriptsSpec.groovy
          job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/structs/DescribableContextSpec.groovy
          job-dsl-plugin/src/test/resources/javaposse/jobdsl/plugin/gstring.groovy
          http://jenkins-ci.org/commit/job-dsl-plugin/b1bcdc6790446e1a74c37d6d93740589119117a3
          Log:
          allow GString as argument type for auto-generated DSL

          [FIXES JENKINS-39153]

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: docs/Home.md job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/structs/DescribableContext.groovy job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/ExecuteDslScriptsSpec.groovy job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/structs/DescribableContextSpec.groovy job-dsl-plugin/src/test/resources/javaposse/jobdsl/plugin/gstring.groovy http://jenkins-ci.org/commit/job-dsl-plugin/b1bcdc6790446e1a74c37d6d93740589119117a3 Log: allow GString as argument type for auto-generated DSL [FIXES JENKINS-39153]

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          docs/Home.md
          job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/structs/DescribableContext.groovy
          job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/ExecuteDslScriptsSpec.groovy
          job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/structs/DescribableContextSpec.groovy
          job-dsl-plugin/src/test/resources/javaposse/jobdsl/plugin/gstring.groovy
          http://jenkins-ci.org/commit/job-dsl-plugin/312a71e6ab0333c23f59e01992c82df882d32149
          Log:
          Merge pull request #942 from daspilker/JENKINS-39153

          JENKINS-39153 allow GString as argument type for auto-generated DSL

          Compare: https://github.com/jenkinsci/job-dsl-plugin/compare/9a9e94c68d12...312a71e6ab03

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: docs/Home.md job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/structs/DescribableContext.groovy job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/ExecuteDslScriptsSpec.groovy job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/structs/DescribableContextSpec.groovy job-dsl-plugin/src/test/resources/javaposse/jobdsl/plugin/gstring.groovy http://jenkins-ci.org/commit/job-dsl-plugin/312a71e6ab0333c23f59e01992c82df882d32149 Log: Merge pull request #942 from daspilker/ JENKINS-39153 JENKINS-39153 allow GString as argument type for auto-generated DSL Compare: https://github.com/jenkinsci/job-dsl-plugin/compare/9a9e94c68d12...312a71e6ab03

            daspilker Daniel Spilker
            daspilker Daniel Spilker
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: