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

WorkUnitContext.actions does not populate for Pipeline steps

      I found this while filing JENKINS-37809. It seems like WorkUnitContext objects created by Pipeline steps do not have their parameters storied in the .actions field. The plugin works by calling getCurrentWorkUnit() on a node's Executor, uses that WorkUnit's .context to get the WorkUnitContext object, then gets its parameters by referencing the .actions field. That field is populated for builds running on executors for Freestyle jobs, but does not for Pipeline jobs.

      I don't really know much Java or understand the internal workings of Jenkins, so I'm afraid I can't supply much more detail than that. I put as many relevant details as I could in JENKINS-37809 and decided to file a bug with the main pipeline component, as it seems like that is where the underlying issue exists.

      Thanks!

          [JENKINS-37929] WorkUnitContext.actions does not populate for Pipeline steps

          Jesse Glick added a comment -

          A Pipeline node block creates a PlaceholderTask, which is distinct from the WorkflowJob that represents the project as a whole. I am not sure which Action you are looking for specifically, but I would not expect there to be any here. ParametersAction would be associated with the WorkflowRun, not a PlaceholderExecutable within it. Anyway it seems dubious that this is really what you should be basing decisions on. I am not sure what the freestyle feature is intended to accomplish but it possibly does not translate.

          Jesse Glick added a comment - A Pipeline node block creates a PlaceholderTask , which is distinct from the WorkflowJob that represents the project as a whole. I am not sure which Action you are looking for specifically, but I would not expect there to be any here. ParametersAction would be associated with the WorkflowRun , not a PlaceholderExecutable within it. Anyway it seems dubious that this is really what you should be basing decisions on. I am not sure what the freestyle feature is intended to accomplish but it possibly does not translate.

          Jesse Glick added a comment -

          Possibly there is just no API for this. SubTask has getOwnerTask, but Executable has no getOwnerExecutable. Would require a core change to have a place to even offer the link from a PlaceholderExecutable to a WorkflowRun.

          Jesse Glick added a comment - Possibly there is just no API for this. SubTask has getOwnerTask , but Executable has no getOwnerExecutable . Would require a core change to have a place to even offer the link from a PlaceholderExecutable to a WorkflowRun .

          Hey Jesse, thanks for the response. The intended use case was to get the parameters and their values from the currently running builds in a pipeline project. WorkUnitContext.actions seemed to be the way to do that in the past, but it doesn't look like the api supports it for pipelines.

          In any case, thanks for taking a look. Much appreciated.

          Aaron Lunsford added a comment - Hey Jesse, thanks for the response. The intended use case was to get the parameters and their values from the currently running builds in a pipeline project. WorkUnitContext.actions seemed to be the way to do that in the past, but it doesn't look like the api supports it for pipelines. In any case, thanks for taking a look. Much appreciated.

          Rurui Ye added a comment -

          this is still a blocking issue for jenkins, way does it resolved?

          Rurui Ye added a comment - this is still a blocking issue for jenkins, way does it resolved?

          Jesse Glick added a comment -

          yeluolei see above comments. Jenkins is behaving as designed.

          Jesse Glick added a comment - yeluolei see above comments. Jenkins is behaving as designed.

            jglick Jesse Glick
            alunsford Aaron Lunsford
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: