[JIRA] (JENKINS-58124) During Jenkinsfile import Triple Single Quoted String is evaluating the dollar sign inside it.

1 view
Skip to first unread message

mmclaughlin@cloudbees.com (JIRA)

unread,
Jun 20, 2019, 2:15:02 PM6/20/19
to jenkinsc...@googlegroups.com
Mitch McLaughlin created an issue
 
Jenkins / Bug JENKINS-58124
During Jenkinsfile import Triple Single Quoted String is evaluating the dollar sign inside it.
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2019-06-20 18:14
Priority: Minor Minor
Reporter: Mitch McLaughlin
  • 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.
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages