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

EnvironmentContributor cannot modify existing environment variable in FreeStyle jobs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      While using EnvironmentContributor to set/modify certain environment variables in our plugin, we've noticed a discrepancy in behavior when FreeStyle and Pipeline jobs are used.

       

      Consider the following environment contributor (https://github.com/jenkinsci/gradle-plugin/blob/master/src/main/java/hudson/plugins/gradle/injection/GradleInjectionEnvironmentContributor.java) in our gradle-plugin (https://github.com/jenkinsci/gradle-plugin)

      Here, we're setting a new environment variable if the condition is met and it gets properly propagated to the build for both FreeStyle and Pipeline job configurations.

       

      However, we also have another environment contributor (https://github.com/jenkinsci/gradle-plugin/blob/master/src/main/java/hudson/plugins/gradle/injection/MavenInjectionEnvironmentContributor.java), which modifies existing environment variables (MAVEN_OPTS and JENKINSGRADLEPLUGIN_MAVEN_PLUGIN_CONFIG_EXT_CLASSPATH are already set before this contributor is invoked and exist in EnvVars.)

      For some reason, modifying these variables only works for Pipeline jobs; for FreeStyle ones the modification doesn't have any effect and old values are used in the job.

       

      Basically, adding new variables to the EnvVars works for both types of jobs, but modification of existing ones works only for Pipeline ones. At first glance, this looks like a bug, but, perhaps, there is a reason it behaves like that. 

            Unassigned Unassigned
            welandaz Iurii Ignatko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: