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

CulpritsRecipientProvider does not work with pipeline

    XMLWordPrintable

Details

    Description

      as you can see in the following code, in our case, the run is always an instance of WorkflowRun, and the runResult is always Result.SUCCESS, so no user would be add to recipient.

      https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java

              if (run instanceof AbstractBuild) {
                  Set<User> users = ((AbstractBuild<?,?>)run).getCulprits();
                  RecipientProviderUtilities.addUsers(users, context.getListener(), env, to, cc, bcc, debug);
              } else if (runResult != null && runResult.isWorseThan(Result.SUCCESS)) {
                  List<Run<?, ?>> builds = new ArrayList<>();
                  Run<?, ?> build = run;
                  while (build != null) {
                      final Result buildResult = build.getResult();
                      if (buildResult != null) {
                          if (buildResult.isWorseThan(Result.SUCCESS)) {
                              debug.send("Including build %s with status %s", build.getId(), buildResult);
                              builds.add(build);
                          } else {
                              break;
                          }
                      }
                      build = build.getPreviousCompletedBuild();
                  }
                  Set<User> users = RecipientProviderUtilities.getChangeSetAuthors(builds, debug);
                  RecipientProviderUtilities.addUsers(users, context.getListener(), env, to, cc, bcc, debug);
      }
      

      Attachments

        Issue Links

          Activity

            cdlee Makson Lee created issue -
            cdlee Makson Lee made changes -
            Field Original Value New Value
            Description as you can see in the following code, in our case, the run is always an instance of WorkflowRun, and the runResult is always Result.SUCCESS, so no user would be add to recipient.


            https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java

            {code:java}
                    if (run instanceof AbstractBuild) {
                        Set<User> users = ((AbstractBuild<?,?>)run).getCulprits();
                        RecipientProviderUtilities.addUsers(users, context.getListener(), env, to, cc, bcc, debug);
                    } else if (runResult != null && runResult.isWorseThan(Result.SUCCESS)) {
                        List<Run<?, ?>> builds = new ArrayList<>();
                        Run<?, ?> build = run;
                        while (build != null) {
                            final Result buildResult = build.getResult();
                            if (buildResult != null) {
                                if (buildResult.isWorseThan(Result.SUCCESS)) {
                                    debug.send("Including build %s with status %s", build.getId(), buildResult);
                                    builds.add(build);
                                } else {
                                    break;
                                }
                            }
                            build = build.getPreviousCompletedBuild();
                        }
                        Set<User> users = RecipientProviderUtilities.getChangeSetAuthors(builds, debug);
                        RecipientProviderUtilities.addUsers(users, context.getListener(), env, to, cc, bcc, debug);
            }
            {code}
            davidvanlaatum David van Laatum made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            davidvanlaatum David van Laatum made changes -
            Link This issue is blocked by JENKINS-39925 [ JENKINS-39925 ]

            People

              davidvanlaatum David van Laatum
              cdlee Makson Lee
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: