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

Cannot escape comma in envs in Docker Build Step

      We are using Jenkins as a continuous integration for Docker containers. In setting up our hubot, we've run into a problem with creating a container with environment variables.

      The docker-build-step supports adding environment variables as comma delimited. Unfortunately, the hubot-auth plugin requires a comma delimited environment variable and this is the only way to grant user credentials. Since there is no way to escape the comma in the docker-build-step Environment Variables field, I cannot properly set this variable.

      ref. Ref. https://github.com/hubot-scripts/hubot-auth/blob/master/src/auth.coffee#L21-L23

      If it's helpful, I've tried quoting (double and single, with and without backslash), backslash escaping, double comma, and adding it twice. I've also tried using an XML comma encode directly in the config.xml.

      As such, we're unable to use Jenkins to directly manage this job. I should note that Ansible has a similar nomenclature but can still populate this correctly (probably due to the yaml->list).

      Simply allowing a method to escape commas in this field would allow for this type of setup to be used in Jenkins.

          [JENKINS-31350] Cannot escape comma in envs in Docker Build Step

          Scott Williams added a comment - - edited

          It looks like this can be patched in:

          if (!envVarsRes.isEmpty()) {
          String[] envVarResSplitted = envVarsRes.split(",");
          cfgCmd.withEnv(envVarResSplitted);
          }

          line 120 of CreateContainerCommand.java

          A basic CSV reader should handle escapes, for perhaps something like this: http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes

          Scott Williams added a comment - - edited It looks like this can be patched in: if (!envVarsRes.isEmpty()) { String[] envVarResSplitted = envVarsRes.split(","); cfgCmd.withEnv(envVarResSplitted); } line 120 of CreateContainerCommand.java A basic CSV reader should handle escapes, for perhaps something like this: http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes

            vjuranek vjuranek
            sawilliams Scott Williams
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: