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

          Daniel Spilker created issue -
          Daniel Spilker made changes -
          Remote Link New: This issue links to "Groovy script fails to call Slack notification parameter from Jenkins DSL job (Web Link)" [ 14969 ]
          Rachel M. made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Rachel M. made changes -
          Assignee Original: Daniel Spilker [ daspilker ] New: Rachel M. [ rachel ]

          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 ) } } }
          Rachel M. made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

          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.
          Daniel Spilker made changes -
          Resolution Original: Not A Defect [ 7 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
          Rachel M. made changes -
          Assignee Original: Rachel M. [ rachel ] New: Daniel Spilker [ daspilker ]
          Rachel M. made changes -
          Comment [ Oh, sorry deeply [~daspilker], I've just seen you maintain the Job DSL Plugin and I thought it was a user's problem.

          !https://s-media-cache-ak0.pinimg.com/236x/66/92/da/6692da3d184952e8dae08d024ecd0fce.jpg! ]

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

              Created:
              Updated:
              Resolved: