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

EnvInject cannot inject variables whose contents contain a dollar sign ($)

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      If I add an variable in the Jenkins configuration with a dollar sign in the content, then the variable is not injected. The console output says that the variable is unset because it is "unresolved":

      [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
      [EnvInject] - Injecting as environment variables the properties content 
      ADMIN_PASS="pas$word"
      
      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'ADMIN_PASS' variable.
      

      I've tried single quotes and double quotes, escaping with \$ and with $$, and nothing works: every time, the variable is unset. Help?

        Attachments

          Issue Links

            Activity

            Hide
            nickg Nick Grealy added a comment -

            Can you please check whether this issue is still occurring with recent versions of the plugin?

            Show
            nickg Nick Grealy added a comment - Can you please check whether this issue is still occurring with recent versions of the plugin?
            Hide
            fayez Fayez ALSEDLAH added a comment -

            Hello guys,

            I'm using EnvIjnect version : 1.92.1, and I still have the same problem my password is 'AL$$PWS' but when it comes to the output I only get 'AL$PWS'. I've also tried different way to escape none of them work even I tried to put $$$$ but still the output with only one dollar sign.

            Thanks

            Show
            fayez Fayez ALSEDLAH added a comment - Hello guys, I'm using EnvIjnect version : 1.92.1, and I still have the same problem my password is 'AL$$PWS' but when it comes to the output I only get 'AL$PWS'. I've also tried different way to escape none of them work even I tried to put $$$$ but still the output with only one dollar sign. Thanks
            Hide
            apgray Andrew Gray added a comment - - edited

            I am using EnvInject version 1.92.1 and also have the same issue.

            I am trying to set a variable called DRIVE_LETTER="D$"

            How can we properly escape a trailing $ character?

            Show
            apgray Andrew Gray added a comment - - edited I am using EnvInject version 1.92.1 and also have the same issue. I am trying to set a variable called DRIVE_LETTER="D$" How can we properly escape a trailing $ character?
            Hide
            apgray Andrew Gray added a comment -

            Jenkins Core: 2.12
            EnvInject: 1.92.1

            I tried the following evaluated groovy script:

            switch (ENV) {
                    case 'DEV':
            		def map = [WEB_SERVER: '<machine name>.', DB_SERVER: '<machine name>', DRIVE_LETTER: 'D$$']
            		return map
            		break
            	case 'TEST':
            		def map = [WEB_SERVER: '<machine name>', DB_SERVER: '<machine name>', DRIVE_LETTER: 'D$$']
            		return map
            		break
            default:
            		def map = [WEB_SERVER: '', DB_SERVER: '', DRIVE_LETTER: '']
            		return map
            		break
            }
            

            which still didn't work when ENV = 'DEV' or 'TEST'.

            [EnvInject] - Injecting contributions.
            Building in workspace ...
            [EnvInject] - Unset unresolved 'DRIVE_LETTER' variable.
            
            

            If I downgrade to Jenkins Core 2.11 and run the same code I get the same result.

            If I remove the trailing $ from DRIVE_LETTER it works. So that confirms to me that it doesn't like the trailing $ character.

            Can anyone assist with how to escape this $ in this context?

            Show
            apgray Andrew Gray added a comment - Jenkins Core: 2.12 EnvInject: 1.92.1 I tried the following evaluated groovy script: switch (ENV) { case 'DEV' : def map = [WEB_SERVER: '<machine name>.' , DB_SERVER: '<machine name>' , DRIVE_LETTER: 'D$$' ] return map break case 'TEST' : def map = [WEB_SERVER: '<machine name>' , DB_SERVER: '<machine name>' , DRIVE_LETTER: 'D$$' ] return map break default : def map = [WEB_SERVER: '', DB_SERVER: ' ', DRIVE_LETTER: ' '] return map break } which still didn't work when ENV = 'DEV' or 'TEST'. [EnvInject] - Injecting contributions. Building in workspace ... [EnvInject] - Unset unresolved 'DRIVE_LETTER' variable. If I downgrade to Jenkins Core 2.11 and run the same code I get the same result. If I remove the trailing $ from DRIVE_LETTER it works. So that confirms to me that it doesn't like the trailing $ character. Can anyone assist with how to escape this $ in this context?
            Hide
            wvidana Wilfrido Vidana added a comment - - edited

            On a linux box this can be solved placing #!/bin/bash at the beggining of the properties file.

            EDIT: not even the bashline works if the options "keep jenkins enrionment variables" and "keep jenkins build variables" are checked. Without them the "$" does pass to the script

            Show
            wvidana Wilfrido Vidana added a comment - - edited On a linux box this can be solved placing #!/bin/bash at the beggining of the properties file. EDIT: not even the bashline works if the options "keep jenkins enrionment variables" and "keep jenkins build variables" are checked. Without them the "$" does pass to the script

              People

              • Assignee:
                Unassigned
                Reporter:
                singingwolfboy David Baumgold
              • Votes:
                4 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated: