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

Environment variables from EnvInject plugin are not inherited/parsed by batch tasks

      Environment variables set for a job with the "Prepare an environment for the run" and not processed/used for batch tasks. This is very similar to bug JENKINS-5580 reported for batch tasks and the now deprecated setenv plugin

          [JENKINS-13647] Environment variables from EnvInject plugin are not inherited/parsed by batch tasks

          tsondergaard created issue -

          Could you attach your job configuration file (config.xml)?

          Gregory Boissinot added a comment - Could you attach your job configuration file (config.xml)?

          tsondergaard added a comment -

          Note that in the attached config.xml the environment variables (EVVERSION among others) are manually duplicated in the make-release batch task (to make it work)

          tsondergaard added a comment - Note that in the attached config.xml the environment variables (EVVERSION among others) are manually duplicated in the make-release batch task (to make it work)
          tsondergaard made changes -
          Attachment New: config.xml [ 21777 ]

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          pom.xml
          src/main/java/hudson/plugins/batch_task/BatchRun.java
          http://jenkins-ci.org/commit/batch-task-plugin/69b3bde996d5500b18c69f582c7c14e5d1ef9fe4
          Log:
          Fix JENKINS-13647

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: pom.xml src/main/java/hudson/plugins/batch_task/BatchRun.java http://jenkins-ci.org/commit/batch-task-plugin/69b3bde996d5500b18c69f582c7c14e5d1ef9fe4 Log: Fix JENKINS-13647
          Gregory Boissinot made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          The use of EnvVarsResolver in that commit seems to cause a blocker issue when running a batch task. Nothing happens on the GUI, the console is empty, here's the server log stacktrace:

          hudson.model.Executor run
          SEVERE: Executor threw an exception
          java.lang.NullPointerException: Current Project is null
                  at com.sonyericsson.rebuild.RebuildAction.getProject(RebuildAction.java:117)
                  at com.sonyericsson.rebuild.RebuildAction.getUrlName(RebuildAction.java:144)
                  at org.jenkinsci.lib.envinject.service.EnvInjectActionRetriever.getEnvInjectAction(EnvInjectActionRetriever.java:32)
                  at org.jenkinsci.lib.envinject.service.EnvVarsResolver.getEnVars(EnvVarsResolver.java:51)
                  at hudson.plugins.batch_task.BatchRun.run(BatchRun.java:224)
                  at hudson.model.ResourceController.execute(ResourceController.java:88)
                  at hudson.model.Executor.run(Executor.java:239)
          

          Tested with Jenkins 1.460 and 1.463

          Julien Carsique added a comment - The use of EnvVarsResolver in that commit seems to cause a blocker issue when running a batch task. Nothing happens on the GUI, the console is empty, here's the server log stacktrace: hudson.model.Executor run SEVERE: Executor threw an exception java.lang.NullPointerException: Current Project is null at com.sonyericsson.rebuild.RebuildAction.getProject(RebuildAction.java:117) at com.sonyericsson.rebuild.RebuildAction.getUrlName(RebuildAction.java:144) at org.jenkinsci.lib.envinject.service.EnvInjectActionRetriever.getEnvInjectAction(EnvInjectActionRetriever.java:32) at org.jenkinsci.lib.envinject.service.EnvVarsResolver.getEnVars(EnvVarsResolver.java:51) at hudson.plugins.batch_task.BatchRun.run(BatchRun.java:224) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:239) Tested with Jenkins 1.460 and 1.463

          Gregory Boissinot added a comment - - edited

          According to the trace, it is due to the rebuild Jenkins Plugin

          AbstractProject currentProject = null;
          StaplerRequest request = Stapler.getCurrentRequest();
          if (request != null) {
           currentProject = request.findAncestorObject(AbstractProject.class);
          }
          if (currentProject == null) {
           throw new NullPointerException("Current Project is null");
          }
          

          Gregory Boissinot added a comment - - edited According to the trace, it is due to the rebuild Jenkins Plugin AbstractProject currentProject = null ; StaplerRequest request = Stapler.getCurrentRequest(); if (request != null ) { currentProject = request.findAncestorObject(AbstractProject.class); } if (currentProject == null ) { throw new NullPointerException( "Current Project is null " ); }

          Well, I don't know since downgrading batch-task is fixing the issue, even if it's the rebuild-plugin which throws the exception. I'm not sure to understand why the rebuild-plugin is called when executing a batch task, but if it was already called before that change, then its "current project" wasn't null...
          Do you think the use of EnvInject in batch-task requires some upgrade on rebuild-plugin? Isn't there a broken backward compatibility which could be fixed in EnvInject?

          Julien Carsique added a comment - Well, I don't know since downgrading batch-task is fixing the issue, even if it's the rebuild-plugin which throws the exception. I'm not sure to understand why the rebuild-plugin is called when executing a batch task, but if it was already called before that change, then its "current project" wasn't null... Do you think the use of EnvInject in batch-task requires some upgrade on rebuild-plugin? Isn't there a broken backward compatibility which could be fixed in EnvInject?

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/com/sonyericsson/rebuild/RebuildAction.java
          http://jenkins-ci.org/commit/rebuild-plugin/1b940ee344354bef8f8a1629c219dd453e2c903c
          Log:
          Fix for JENKINS-13647
          Avoid NullPointerException on the getProject() method when getURL() method is call from a content where your can't retrieve a Project object in the request (such as in the batch-task plugin)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/com/sonyericsson/rebuild/RebuildAction.java http://jenkins-ci.org/commit/rebuild-plugin/1b940ee344354bef8f8a1629c219dd453e2c903c Log: Fix for JENKINS-13647 Avoid NullPointerException on the getProject() method when getURL() method is call from a content where your can't retrieve a Project object in the request (such as in the batch-task plugin)

            gbois Gregory Boissinot
            tsondergaard tsondergaard
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: