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

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

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • envinject-plugin
    • None

      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?

          [JENKINS-13157] EnvInject cannot inject variables whose contents contain a dollar sign ($)

          David Baumgold created issue -
          David Baumgold made changes -
          Description Original: 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?
          New: 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":

          {code}
          [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.
          {code}

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

          With this king of value, EnvInject doesn't know if it is a characater or $word is a variable to resolve.
          I suggest you should use an alternate: EnvInject password in the 'Prepare environment' section.
          Could it suit you?

          Gregory Boissinot added a comment - With this king of value, EnvInject doesn't know if it is a characater or $word is a variable to resolve. I suggest you should use an alternate: EnvInject password in the 'Prepare environment' section. Could it suit you?
          Gregory Boissinot made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          I can give that a try. However, it doesn't really address the problem: I expect to be able to insert a literal $ by escaping it somehow. In bash, "pas$word" is treated as "pas" followed by the contents of the $word variable, but "pas\$word" is treated as the literal string "pas$word": the backslash escapes the dollar sign. Could EnvInject support escaping in the same way? (In bash, if you want to insert a literal backslash, you have to escape it as well: "a
          b" is treated as the literal string "a\b".)

          David Baumgold added a comment - I can give that a try. However, it doesn't really address the problem: I expect to be able to insert a literal $ by escaping it somehow. In bash, "pas$word" is treated as "pas" followed by the contents of the $word variable, but "pas\$word" is treated as the literal string "pas$word": the backslash escapes the dollar sign. Could EnvInject support escaping in the same way? (In bash, if you want to insert a literal backslash, you have to escape it as well: "a b" is treated as the literal string "a\b".)

          And apparently Jira interprets a double-backslash as a newline. That last sentence should have "a-backslash-backslash-b", not "a-newline-b".

          David Baumgold added a comment - And apparently Jira interprets a double-backslash as a newline. That last sentence should have "a-backslash-backslash-b", not "a-newline-b".

          And apparently Jira interprets a double-backslash as a newline. That last sentence should have "a-backslash-backslash-b", not "a-newline-b".

          David Baumgold added a comment - And apparently Jira interprets a double-backslash as a newline. That last sentence should have "a-backslash-backslash-b", not "a-newline-b".

          Gabriele Giuseppini added a comment - - edited

          Same here. I have a variable defined as:
          DBName=Jenkins${SVN_REVISION}

          And after upgrading from 1.0 to 1.40, EnvInject stopped creating the new variable.

          Uh, sorry - after reading the latest comments, I need to clarify that I'm trying to get EnvInject to resolve the nested variables, with no luck in 1.40.

          Gabriele Giuseppini added a comment - - edited Same here. I have a variable defined as: DBName=Jenkins${SVN_REVISION} And after upgrading from 1.0 to 1.40, EnvInject stopped creating the new variable. Uh, sorry - after reading the latest comments, I need to clarify that I'm trying to get EnvInject to resolve the nested variables, with no luck in 1.40.

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java
          http://jenkins-ci.org/commit/envinject-plugin/7cad840a6f897438c855d10b556e142ef8c465a2
          Log:
          Fix JENKINS-13157

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java http://jenkins-ci.org/commit/envinject-plugin/7cad840a6f897438c855d10b556e142ef8c465a2 Log: Fix JENKINS-13157

          Escaping with a slash is a good idea.
          Please upgrade to EnvInject 1.41

          Gregory Boissinot added a comment - Escaping with a slash is a good idea. Please upgrade to EnvInject 1.41
          Gregory Boissinot made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

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

              Created:
              Updated: