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

CulpritsRecipientProvider does not work with pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      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

            Hide
            davidvanlaatum David van Laatum added a comment -

            This should work fine. Is your pipelines build status being updated by something prior to calling this?

            Show
            davidvanlaatum David van Laatum added a comment - This should work fine. Is your pipelines build status being updated by something prior to calling this?
            Hide
            cdlee Makson Lee added a comment -

            the inline document for Curlprits says,

            "Sends email to the list of users who committed a change since the last non-broken build till now. This list at least always include people who made changes in this build, but if the previous build was a failure it also includes the culprit list from there."

            so even the current build result is Result.SUCCESS, people who made changes in current build should be added to recipient, right?

            Show
            cdlee Makson Lee added a comment - the inline document for Curlprits says, "Sends email to the list of users who committed a change since the last non-broken build till now. This list at least always include people who made changes in this build , but if the previous build was a failure it also includes the culprit list from there." so even the current build result is Result.SUCCESS, people who made changes in current build should be added to recipient, right?
            Hide
            davidvanlaatum David van Laatum added a comment -

            true. Does it work for you if the current build is not successful though?

            Show
            davidvanlaatum David van Laatum added a comment - true. Does it work for you if the current build is not successful though?
            Hide
            davidvanlaatum David van Laatum added a comment -

            ie if its just the && runResult.isWorseThan(Result.SUCCESS) thats stopping it, easy fix

            Show
            davidvanlaatum David van Laatum added a comment - ie if its just the && runResult.isWorseThan(Result.SUCCESS) thats stopping it, easy fix
            Hide
            cdlee Makson Lee added a comment - - edited

            this works,

            node ('docker'){
                try {
                    checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/master']], userRemoteConfigs: [[url: 'git://server/test']]])
                    error ""
                    currentBuild.result = 'SUCCESS'
                } catch (Exception e) {
                    currentBuild.result = 'FAILURE'
                }
                emailext body: "test", recipientProviders: [[$class: 'CulpritsRecipientProvider']], subject: "test"
            }
            

            this does not,

            node ('docker'){
                try {
                    checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/master']], userRemoteConfigs: [[url: 'git://server/test']]])
                    //error ""
                    currentBuild.result = 'SUCCESS'
                } catch (Exception e) {
                    currentBuild.result = 'FAILURE'
                }
                emailext body: "test", recipientProviders: [[$class: 'CulpritsRecipientProvider']], subject: "test"
            }
            
            Show
            cdlee Makson Lee added a comment - - edited this works, node ( 'docker' ){ try { checkout([$class: 'GitSCM' , branches: [[name: 'refs/heads/master' ]], userRemoteConfigs: [[url: 'git: //server/test' ]]]) error "" currentBuild.result = 'SUCCESS' } catch (Exception e) { currentBuild.result = 'FAILURE' } emailext body: "test" , recipientProviders: [[$class: 'CulpritsRecipientProvider' ]], subject: "test" } this does not, node ( 'docker' ){ try { checkout([$class: 'GitSCM' , branches: [[name: 'refs/heads/master' ]], userRemoteConfigs: [[url: 'git: //server/test' ]]]) //error "" currentBuild.result = 'SUCCESS' } catch (Exception e) { currentBuild.result = 'FAILURE' } emailext body: "test" , recipientProviders: [[$class: 'CulpritsRecipientProvider' ]], subject: "test" }
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: David van Laatum
            Path:
            src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java
            src/test/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProviderTest.java
            http://jenkins-ci.org/commit/email-ext-plugin/60629e806a83d66a866b8985b3dbf2108642f240
            Log:
            fix JENKINS-40653 CulpritsRecipientProvider does not work with pipeline

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David van Laatum Path: src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java src/test/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProviderTest.java http://jenkins-ci.org/commit/email-ext-plugin/60629e806a83d66a866b8985b3dbf2108642f240 Log: fix JENKINS-40653 CulpritsRecipientProvider does not work with pipeline
            Hide
            davidvanlaatum David van Laatum added a comment -

            ver 2.53 released will show up in updates in the next few hours or you can download from https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/email-ext/2.53/email-ext-2.53.hpi and install manually

            Show
            davidvanlaatum David van Laatum added a comment - ver 2.53 released will show up in updates in the next few hours or you can download from https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/email-ext/2.53/email-ext-2.53.hpi and install manually
            Hide
            cdlee Makson Lee added a comment -

            thanks.

            Show
            cdlee Makson Lee added a comment - thanks.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: