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

During Jenkinsfile import Triple Single Quoted String is evaluating the dollar sign inside it.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline
    • None

      • Summary. A Jenkinsfile containing strings is using triple-single quoted strings which should not support interpolation. However, on import an error is thrown because of a dollar sign in this string. Syntax of the string itself appears correct.
      • Steps to reproduce. Issue exists in single environment and has not yet been reproducible.
      • Expected behavior. Due to the use of a non interpolated string in the groovy, a dollar sign in the string should result in nothing taking place on parsing of the Jenkinsfile
      • Actual behavior. When the Jenkinsfile is imported, it throws this error:
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
      WorkflowScript: 140: illegal string body character after dollar sign; 
      solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 140, column 58. 
      --stack-name "${THISARN}" | grep

      The stage that causes this error is:

      stage('Selecte an Account') { 
      steps { 
      script { 
      env.ACCOUNTDATA = input message: 'Pick AWS Account', 
      parameters: [choice(name: 'ACCOUNTDATA', choices: AccountMap.toList(), description: 'AWS account name and number')] 
      env.ACCOUNTNAME = sh( 
      script: '''\ 
      #!/bin/bash\ 
      echo "${env.ACCOUNTDATA}" | awk -F ":" '{print $1}'\
      ''', returnStdout: true) 
      env.ACCOUNTNUMBER = sh( 
      script: '''\ 
      #!/bin/bash \ 
      echo "${env.ACCOUNTDATA}" | awk -F ":" '{print $2}'\
      ''', returnStdout: true) 
      } 
      } 
      }
      • Workaround.  Defining the variable using env.VARIABLE or using a def variable allows this to work as expected.
      • Business impact. This issue is hindering the ability to quickly move existing shell scripts from an environment into a Jenkinsfile. The workaround allows proper functionality, but isn't ideal.

            Unassigned Unassigned
            mmclaughlin Mitch McLaughlin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: