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

EnvInjector plugin generates error when env variable already exists

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

      In the virtual machine OS environment, there is a variable with the name EXAMPLE_VARIALBE. The variable has a default value which is needed by local tools. In Jenkins jobs, I am using the EnvInject plugin to inject new environment variables but also to overwrite EXAMPLE_VARIALBE with a new value. This is standard action, however, after upgrading the Environment Injector plugin from 2.4.0 to the newest one, it started to generate an error:

      ERROR: Not all environment variables could be successfully injected. Check for similarly-named environment variables.

      Catching such behavior was introduced due to a ticket: https://issues.jenkins.io/browse/JENKINS-60559

      https://github.com/jenkinsci/envinject-plugin/commit/25669f16a5b0bb20dc97cc29e8c237bec77ab2db

      And for unknown reasons, the warning message was changed to error one, which in my opinion is completely incorrect and misleading:

      https://github.com/jenkinsci/envinject-plugin/commit/1bd30955b37acce2e81ccc871c7642ebf4344e03

      First, the message should be clearer and inform the user of what is really happening. It could be a warning or just information, but not an error.

      Second, the case from https://issues.jenkins.io/browse/JENKINS-60559 should also be caught separately, as the first message concerns a different case.

          [JENKINS-71343] EnvInjector plugin generates error when env variable already exists

          Jacek added a comment -

          Could you change this misleading message, which is printed when you inject env that already exists in the given environment:
                  misleading message (used by updated EnvInjector plugin when one of injected env that already exist):
                  ERROR: Not all environment variables may have been successfully injected. Check environment variables with similar names.
          To:
                  more appropriate message:
                  WARNNING: The environment variable already exists and has been overwritten by the EnvInjector plug-in. <env_name>=<value_before_injection> overwritten to <env_name>=<value_after_injection>

          Or at least please bring back this as a warning and not an error, as EnvInect overwrites envs without an issue:
                  WARNING: Not all environment variables may have been successfully injected. Check environment variables with similar names.

           

          Jacek added a comment - Could you change this misleading message, which is printed when you inject env that already exists in the given environment:         misleading message (used by updated EnvInjector plugin when one of injected env that already exist):         ERROR: Not all environment variables may have been successfully injected. Check environment variables with similar names. To:         more appropriate message:         WARNNING: The environment variable already exists and has been overwritten by the EnvInjector plug-in. <env_name>=<value_before_injection> overwritten to <env_name>=<value_after_injection> Or at least please bring back this as a warning and not an error, as EnvInect overwrites envs without an issue:         WARNING: Not all environment variables may have been successfully injected. Check environment variables with similar names.  

          My build logs are now getting filled up with hundreds of these messages.  Since the build hasn't changed (only the version of Jenkins and/or the plugin), it would be nice to revert marking this as an error...

          Robert Patrick added a comment - My build logs are now getting filled up with hundreds of these messages.  Since the build hasn't changed (only the version of Jenkins and/or the plugin), it would be nice to revert marking this as an error...

          Jim Searle added a comment -

          Please revert this back to a warning. Better yet, instead of just counting the number of variables before != number of variables after + injected, just check that the injected variables end up in the environment with the proper value.

          Jim Searle added a comment - Please revert this back to a warning. Better yet, instead of just counting the number of variables before != number of variables after + injected, just check that the injected variables end up in the environment with the proper value.

          Typical, no response for this issue...my Jenkins log is useless because my builds have thousands of these messages so it is almost impossible to see any actual errors.

          Robert Patrick added a comment - Typical, no response for this issue...my Jenkins log is useless because my builds have thousands of these messages so it is almost impossible to see any actual errors.

            Unassigned Unassigned
            p_jaskowiec Piotr
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: