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

Customized Post Build Comment ignored for multi-configuration projects

      The "Post Build Comment" settings are ignored for some jobs. Instead, Jenkins posts the default comments to Stash. I tried customizing several jobs, and I see that the customization is ignored if and only if it's a multi-configuration project. Free-style projects support customized messages.

          [JENKINS-55853] Customized Post Build Comment ignored for multi-configuration projects

          Sorry, I don't really use multiconfiguration projects so I can't help here. Will be glad to review a PR though

          Jakub Bochenski added a comment - Sorry, I don't really use multiconfiguration projects so I can't help here. Will be glad to review a PR though

          Pavel Roskin added a comment -

          As I suspected, there is some data that is created in the child builds but consumed in the top level build.

          Specifically, StashPostBuildComment.perform() is run in child executors and creates StashPostBuildCommentAction objects. Then StashBuilds.onCompleted() is run in the top level project and tries to get comments from StashPostBuildCommentAction. It gets null, quite expectedly.

          Pavel Roskin added a comment - As I suspected, there is some data that is created in the child builds but consumed in the top level build. Specifically, StashPostBuildComment.perform() is run in child executors and creates StashPostBuildCommentAction objects. Then StashBuilds.onCompleted() is run in the top level project and tries to get comments from StashPostBuildCommentAction. It gets null, quite expectedly.

          Pavel Roskin added a comment -

          I tried to fix the issue, but my knowledge of Jenkins internals is insufficient. Let's me just describe where I stopped.

          One approach is to introduce a dependency on the Matrix plugin. email-ext-plugins is an example of such code. It can select whether the post-build action happens in child builds, in the top-level build or in both. But I would rather avoid adding a dependency.

          I believe that StashPostBuildComment.perform() is not the best place to publish the configuration of StashPostBuildComment, as it happens in a child build. But I've noticed getRootProject() and getRootBuild(), I'll see if they would help.

          A cleaner approach would be to examine the project for an object of the given class, just like it's done for the trigger. StashBuild.onCompleted() calls StashBuildTrigger.getTrigger(build.getProject()), which is implemented using project's getTrigger(). That would make it possible to read the StashPostBuildComment configuration from the project. But I don't see such method for post-build actions.

          Another approach would be to make StashPostBuildComment listen to some event that happens for the top-level build and publish its configuration with addAction to that build.

          Pavel Roskin added a comment - I tried to fix the issue, but my knowledge of Jenkins internals is insufficient. Let's me just describe where I stopped. One approach is to introduce a dependency on the Matrix plugin. email-ext-plugins is an example of such code. It can select whether the post-build action happens in child builds, in the top-level build or in both. But I would rather avoid adding a dependency. I believe that StashPostBuildComment.perform() is not the best place to publish the configuration of StashPostBuildComment, as it happens in a child build. But I've noticed getRootProject() and getRootBuild(), I'll see if they would help. A cleaner approach would be to examine the project for an object of the given class, just like it's done for the trigger. StashBuild.onCompleted() calls StashBuildTrigger.getTrigger(build.getProject()), which is implemented using project's getTrigger(). That would make it possible to read the StashPostBuildComment configuration from the project. But I don't see such method for post-build actions. Another approach would be to make StashPostBuildComment listen to some event that happens for the top-level build and publish its configuration with addAction to that build.

          Pavel Roskin added a comment -

          Indeed, it's possible to get the StashPostBuildComment object from the project using getPublishersList(). PR posted: https://github.com/jenkinsci/stash-pullrequest-builder-plugin/pull/43

          Pavel Roskin added a comment - Indeed, it's possible to get the StashPostBuildComment object from the project using getPublishersList(). PR posted: https://github.com/jenkinsci/stash-pullrequest-builder-plugin/pull/43

            proski Pavel Roskin
            proski Pavel Roskin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: