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

Env-inject writing \u0000 in injectedEnvVars.txt from windows slave

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • envinject-plugin
    • jenkins master:
      Debian 8
      Jenkins ver. 2.110
      envinject 2.1.3

      jenkins slave:
      Windows Server 2016

      I am having a problem with the envInject, cause it seems to be writing NUL (Unicode 0000 char) from the env of a Windows slave.

       

      1 - Basically I am creating a new job which runs in a Windows slave. This job executes a powershell code that writes variables to a file env.properties (attachment 01.png). I am doing that cause these values are used later in other job steps.

      2 - The file is written without any problems in the windows slave (attachment 02.png)

      3 - When I try to run the job the next time, I have the error:

       

      java.lang.IllegalArgumentException: Invalid environment variable name: "CURRENT_ARCHIVE"
      	at java.lang.ProcessEnvironment.validateName(Unknown Source)
      	at java.lang.ProcessEnvironment.put(Unknown Source)
      	at java.lang.ProcessEnvironment.put(Unknown Source)
      	at hudson.Proc$LocalProc.environment(Proc.java:234)
      	at hudson.Proc$LocalProc.<init>(Proc.java:219)
      

       

      4 - As you can see, apparently the name of the variable is fine. However, if I open the injectedEnvVars.txt in our Linux master, between each char, envinject added a u0000 char, which causes the method ProcessEnvironment.validateName to throw an exception. (see attachments 03 and 04)

       

      All other variables are fine. Just the ones I wrote are messed up. 

       

      Result is that I can run the job only first time. Any subsequent attempt fails, that's why I classified as major. Sorry if this interpretation is incorrect.

       

        1. 01.png
          01.png
          31 kB
        2. 02.png
          02.png
          15 kB
        3. 03.png
          03.png
          22 kB
        4. 04.png
          04.png
          10 kB

          [JENKINS-54369] Env-inject writing \u0000 in injectedEnvVars.txt from windows slave

          Try to change the way, in which you are writting variables to file into following:

          "name=variable" | Out-File env.properties -Encoding ascii  -append

          It helped for me.

          Marek Adamczyk added a comment - Try to change the way, in which you are writting variables to file into following: "name=variable" | Out-File env.properties -Encoding ascii  -append It helped for me.

            Unassigned Unassigned
            robsonhermes Robson Hermes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: