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

parameterized-trigger plugin failed to fetch environment variables from upstream build on version >=2.43.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • jenkins: 2.332.4
      parameterized-trigger: 2.45
      Image: jenkins/jenkins:2.332.4-jdk11
      java.version 11.0.15+10
    • parameterized-trigger-2.45

      Hi,
      We are using parameterized-trigger plugin with combination of build-pipeline-plugin where we connect upstream and downstream Jenkins jobs to form a pipeline view.
      In above scenario if user trigger downstream job manually using pipeline view we are facing issue with fetching environment variables(CapturedEnvironmentAction.class) from upstream build. Add we specifically debugged the issue to SECURITY-2185 fix made on parameterized-trigger plugin.

       
      Here is what we found while debug,
      build-pipeline-plugin invokes the build using BuildCardExtension.java(build-pipeline-plugin) where it invokes getAction method from AbstractBuildParameters.class(parameterized-trigger-plugin) and this invokes getAction(CapturedEnvironmentAction.class) to check if capture is null and at this point return is not null so if condition invoked capture.getCapturedEnvironment()(which is empty) due to SECURITY-2185 changes
       
      public EnvVars getEnvironment(AbstractBuild<?,?> build, TaskListener listener)

                  throws IOException, InterruptedException {

              CapturedEnvironmentAction capture = build.getAction(CapturedEnvironmentAction.class); // not null

              if (capture != null) {

                  return capture.getCapturedEnvironment(); // invoke but got empty 

              } else {

                  return build.getEnvironment(listener);

              }

          } 

      We are able to fix the issue by rolling back these SECURITY-2185 changes from CapturedEnvironmentAction.java but we are hopping for any of your valuable suggestions other than rollback security fixes.

      build-pipeline-plugin 1.5.8
      parameterized-trigger 2.45

      Stacktrace:

      AbstractBuildParameters.getEnvironment(AbstractBuild,TaskListener) (/parameterized-trigger-2.44.jar/hudson.plugins.parameterizedtrigger/AbstractBuildParameters.class:43)
      PredefinedBuildParameters.getAction(AbstractBuild,TaskListener) (/parameterized-trigger-2.44.jar/hudson.plugins.parameterizedtrigger/PredefinedBuildParameters.class:41)
      BuildCardExtension.triggerBuild(AbstractProject,AbstractBuild,Action) (/opt/app/chananne/dev/jenkins-build-pipeline-plugin/src/main/java/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension.java:265)
      BuildCardExtension.triggerManualBuild(ItemGroup,Integer,String,String) (/opt/app/chananne/dev/jenkins-build-pipeline-plugin/src/main/java/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension.java:221)
      BuildPipelineView.triggerManualBuild(Integer,String,String) (/opt/app/chananne/dev/jenkins-build-pipeline-plugin/src/main/java/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView.java:457)
      1145931699.invokeVirtual(Object,Object,Object,Object,Object) (Unknown Source:-1)
      1810471399.invoke(Object,Object,Object,Object,Object) (Unknown Source:-1)
      1203103659.invoke(Object,Object,Object) (Unknown Source:-1)
      Invokers$Holder.invokeExact_MT(Object,Object,Object,Object) (Unknown Source:-1)
      MethodHandle.invokeWithArguments(Object[]) (/java.base/java.lang.invoke/MethodHandle.class:710)
      Function$MethodFunction.invoke(StaplerRequest,StaplerResponse,Object,Object[]) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Function.class:398)
      Function$InstanceFunction.invoke(StaplerRequest,StaplerResponse,Object,Object[]) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Function.class:410)
      Function.bindAndInvoke(Object,StaplerRequest,StaplerResponse,Object[]) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Function.class:208)
      Function.bindAndInvokeAndServeResponse(Object,RequestImpl,ResponseImpl,Object[]) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Function.class:141)
      MetaClass$JavaScriptProxyMethodDispatcher.doDispatch(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/MetaClass.class:661)
      NameBasedDispatcher.dispatch(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/NameBasedDispatcher.class:59)
      Stapler.tryInvoke(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Stapler.class:766)
      Stapler.invoke(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Stapler.class:898)
      MetaClass$9.dispatch(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/MetaClass.class:475)
      Stapler.tryInvoke(RequestImpl,ResponseImpl,Object) (/stapler-1756.vec9071748061.jar/org.kohsuke.stapler/Stapler.class:766)

        1. image_2023-01-09_133015591.png
          250 kB
          Chandrasekhar Anne
        2. image_2023-01-09_134429044.png
          134 kB
          Chandrasekhar Anne
        3. image_2023-01-09_134434510.png
          138 kB
          Chandrasekhar Anne
        4. image_2023-01-09_134440010.png
          140 kB
          Chandrasekhar Anne
        5. image_2023-01-09_135625596.png
          58 kB
          Chandrasekhar Anne

            Unassigned Unassigned
            annechandu Chandrasekhar Anne
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: