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

EnvInject Plugin: option to replace invalid characters in env var names with underscores

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None

      I've got a Java properties file (example attached), which I don't have the ability to modify, that I'm sourcing via EnvInject and this file contains keys which are dot delimited (ex: app.version). EnvInject correctly pulls these in as I've verified on the "Injected environment variables" screen, but they are unresolvable when trying to use them in the job.

      For instance, when trying to use ${app.version} w/the Git plugin to tag a build, I get: "Tag ${app.version}.4 does not exist...", and when I try to use it when executing a shell, I get: "${app.version}: bad substitution". Keys without dots from this same properties file work just fine... unfortunately I need access to the ones w/the dots.

      After doing a bit of research, I understand why this is happening.

      1st of all, you have posted JIRA issues where kohsuke says that env vars w/dots will not be expanded in Jenkins:

      https://issues.jenkins-ci.org/browse/JENKINS-7180

      Then, by doing a quick google search, you'll see that dots in env vars are not supported in most shells and people say to just stay away from them.

      With that in mind, I think a great feature to add to the EnvInject plugin would be to give users the option to replace the dots (and actually any other which are invalid in env var names) that appear in environment variable names with an underscore. If you look at this issue that was opened against the SharedObjects plugin, you'll see that, "...environment variables from tool names replaces a space, a
      dash or a dot to by a underscore."

      https://issues.jenkins-ci.org/browse/JENKINS-13673

      Please see attached properties files and screenshots.

            gbois Gregory Boissinot
            superflav Chris Fraser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: