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

Extra characters in environment variables when using a multi-OS master/slave setup

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

      Hi,
      If I understood it correctly, with the Kubernetes Plugin the "jnp" container is where the Jenkins agent is running. The plugin offers the possibility to execute commands in different containers that are started as part of the pipeline.

      In order to launch commands in those additional containers, the plugin runs "kubectl exec". Before launching the actual command, the plugin executes a block of instructions to set the execution environment correctly. This block contains for example the environment variables available at that stage of the build.

      When preparing the block, the plugin using "println()" to write export instructions:

      out.println(
          String.format(
              windows ? "set %s=%s" : "export %s='%s'",
              entry.getKey(),
              windows ? entry.getValue() : entry.getValue().replace("'", "'\\''")
           )
      );
      

      I believe this causes the block to contain the new line character as configured on the Jenkins Master. In a setup with a Windows Master and Linux Agents, this leads (I think) to additional "\r" characters in the environment variables configured in the additional containers.

      See also my last comment on the issue.

      Regards

          [JENKINS-63847] Extra characters in environment variables when using a multi-OS master/slave setup

            vlatombe Vincent Latombe
            max_laverse Max Laverse
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: