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

EMail-Ext Extended Pipeline Support - Templates

    Details

    • Similar Issues:

      Attachments

        Issue Links

          Activity

          Hide
          mvollmer Marc Vollmer added a comment -

          Would be nice to have this in Pipeline support. We have many jobs using the same templates. When someone joins or leaves the team I just have to edit the matching template and not every build. Since we started mograting builds to pipelines this is a blocker for some builds.

          Show
          mvollmer Marc Vollmer added a comment - Would be nice to have this in Pipeline support. We have many jobs using the same templates. When someone joins or leaves the team I just have to edit the matching template and not every build. Since we started mograting builds to pipelines this is a blocker for some builds.
          Hide
          davidvanlaatum David van Laatum added a comment -

          I am well aware currently waiting on the maintainer of the token-macros plugin to get back to me on a problem I encountered using his beta version that adds pipeline support it seems to work in my test cases just waiting for this problem to be resolved Alex Earl

          Show
          davidvanlaatum David van Laatum added a comment - I am well aware currently waiting on the maintainer of the token-macros plugin to get back to me on a problem I encountered using his beta version that adds pipeline support it seems to work in my test cases just waiting for this problem to be resolved Alex Earl
          Hide
          knut_karlsen Knut Karlsen added a comment -

          Do you have any eta on the fix? We do not have any emails sent from failing pipeline jobs at the moment. Do you know if there is another way to send emails within the pipeline framework?

          Show
          knut_karlsen Knut Karlsen added a comment - Do you have any eta on the fix? We do not have any emails sent from failing pipeline jobs at the moment. Do you know if there is another way to send emails within the pipeline framework?
          Hide
          davidvanlaatum David van Laatum added a comment -

          No I don't you can send emails using this just can't use the template functionality. ie you have to build the contents of the email in the groovy script

          Show
          davidvanlaatum David van Laatum added a comment - No I don't you can send emails using this just can't use the template functionality. ie you have to build the contents of the email in the groovy script
          Hide
          clausfod clausfod added a comment -

          Any news on having the Template support via the Pipeline plugin ?

          Show
          clausfod clausfod added a comment - Any news on having the Template support via the Pipeline plugin ?
          Hide
          budhi003 Ashudeep Budhiraja added a comment -

          Hi Team, David,

          Though email-ext involves lot and may need time, is there any basic level of template support existing currently?

          Thanks.

          Show
          budhi003 Ashudeep Budhiraja added a comment - Hi Team, David, Though email-ext involves lot and may need time, is there any basic level of template support existing currently? Thanks.
          Hide
          davidvanlaatum David van Laatum added a comment -

          The only option at the moment is to build the contents of the email programmatically in the groovy script. I have sent a email to the token macro plugin's maintainer asking for an update

          Show
          davidvanlaatum David van Laatum added a comment - The only option at the moment is to build the contents of the email programmatically in the groovy script. I have sent a email to the token macro plugin's maintainer asking for an update
          Hide
          slide_o_mix Alex Earl added a comment -

          Release has been done

          Show
          slide_o_mix Alex Earl added a comment - Release has been done
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: David van Laatum
          Path:
          pom.xml
          src/main/java/hudson/plugins/emailext/AttachmentUtils.java
          src/main/java/hudson/plugins/emailext/EmailExtTemplateAction.java
          src/main/java/hudson/plugins/emailext/EmailExtTemplateActionFactory.java
          src/main/java/hudson/plugins/emailext/EmailRecipientUtils.java
          src/main/java/hudson/plugins/emailext/EmailType.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
          src/main/java/hudson/plugins/emailext/GroovyScriptPath.java
          src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java
          src/main/java/hudson/plugins/emailext/plugins/CssInliner.java
          src/main/java/hudson/plugins/emailext/plugins/EmailToken.java
          src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/EmailTriggerDescriptor.java
          src/main/java/hudson/plugins/emailext/plugins/RecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/ZipDataSource.java
          src/main/java/hudson/plugins/emailext/plugins/content/AbstractEvalContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/FailedTestsContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ScriptContentBuildWrapper.java
          src/main/java/hudson/plugins/emailext/plugins/content/StaticAnalysisUtilities.java
          src/main/java/hudson/plugins/emailext/plugins/content/TemplateContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/TestCountsContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/TriggerNameContent.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/ListRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/RecipientProviderUtilities.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/RequesterRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/recipients/UpstreamComitterRecipientProvider.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/AbortedTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/AlwaysTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/BuildingTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/FailureTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/FirstUnstableTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/FixedTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/FixedUnhealthyTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/ImprovementTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/NotBuiltTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/NthFailureTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildScriptTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/RegressionTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/ScriptTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/StillFailingTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/StillUnstableTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/SuccessTrigger.java
          src/main/java/hudson/plugins/emailext/plugins/trigger/UnstableTrigger.java
          src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java
          src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java
          src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java
          src/test/java/hudson/plugins/emailext/EmailExtStepTest.java
          src/test/java/hudson/plugins/emailext/EmailTypeTest.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherMatrixTest.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
          src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java
          src/test/java/hudson/plugins/emailext/plugins/CssInlinerTest.java
          src/test/java/hudson/plugins/emailext/plugins/OnlyRegressionsTest.java
          src/test/java/hudson/plugins/emailext/plugins/ZipDataSourceTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/FailedTestsContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/JellyScriptContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/ScriptContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/TestCountsContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/TriggerNameContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/recipients/DevelopersRecipientProviderTest.java
          src/test/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProviderTest.java
          src/test/java/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProviderTest.java
          src/test/java/hudson/plugins/emailext/plugins/recipients/MockUtilities.java
          src/test/java/hudson/plugins/emailext/plugins/recipients/TestUtilities.java
          src/test/java/hudson/plugins/emailext/plugins/trigger/BuildingTriggerTest.java
          src/test/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTriggerTest.java
          src/test/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTriggerTest.java
          src/test/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTriggerTest.java
          src/test/java/hudson/plugins/emailext/plugins/trigger/XNthFailureTriggerTest.java
          src/test/java/hudson/plugins/emailext/recipients/EmailRecipientUtilsTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/15346e064eebf1b870b01a956ff03f92655562c6
          Log:
          [Fix JENKINS-35367] Pipeline templates (#140)

          new token macro version with pipeline support

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David van Laatum Path: pom.xml src/main/java/hudson/plugins/emailext/AttachmentUtils.java src/main/java/hudson/plugins/emailext/EmailExtTemplateAction.java src/main/java/hudson/plugins/emailext/EmailExtTemplateActionFactory.java src/main/java/hudson/plugins/emailext/EmailRecipientUtils.java src/main/java/hudson/plugins/emailext/EmailType.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java src/main/java/hudson/plugins/emailext/GroovyScriptPath.java src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java src/main/java/hudson/plugins/emailext/plugins/CssInliner.java src/main/java/hudson/plugins/emailext/plugins/EmailToken.java src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java src/main/java/hudson/plugins/emailext/plugins/EmailTriggerDescriptor.java src/main/java/hudson/plugins/emailext/plugins/RecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/ZipDataSource.java src/main/java/hudson/plugins/emailext/plugins/content/AbstractEvalContent.java src/main/java/hudson/plugins/emailext/plugins/content/FailedTestsContent.java src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/ScriptContentBuildWrapper.java src/main/java/hudson/plugins/emailext/plugins/content/StaticAnalysisUtilities.java src/main/java/hudson/plugins/emailext/plugins/content/TemplateContent.java src/main/java/hudson/plugins/emailext/plugins/content/TestCountsContent.java src/main/java/hudson/plugins/emailext/plugins/content/TriggerNameContent.java src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/recipients/ListRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/recipients/RecipientProviderUtilities.java src/main/java/hudson/plugins/emailext/plugins/recipients/RequesterRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/recipients/UpstreamComitterRecipientProvider.java src/main/java/hudson/plugins/emailext/plugins/trigger/AbortedTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/AlwaysTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/BuildingTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/FailureTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/FirstUnstableTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/FixedTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/FixedUnhealthyTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/ImprovementTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/NotBuiltTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/NthFailureTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildScriptTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/PreBuildTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/RegressionTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/ScriptTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/StillFailingTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/StillUnstableTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/SuccessTrigger.java src/main/java/hudson/plugins/emailext/plugins/trigger/UnstableTrigger.java src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java src/test/java/hudson/plugins/emailext/EmailExtStepTest.java src/test/java/hudson/plugins/emailext/EmailTypeTest.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherMatrixTest.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java src/test/java/hudson/plugins/emailext/plugins/CssInlinerTest.java src/test/java/hudson/plugins/emailext/plugins/OnlyRegressionsTest.java src/test/java/hudson/plugins/emailext/plugins/ZipDataSourceTest.java src/test/java/hudson/plugins/emailext/plugins/content/FailedTestsContentTest.java src/test/java/hudson/plugins/emailext/plugins/content/JellyScriptContentTest.java src/test/java/hudson/plugins/emailext/plugins/content/ScriptContentTest.java src/test/java/hudson/plugins/emailext/plugins/content/TestCountsContentTest.java src/test/java/hudson/plugins/emailext/plugins/content/TriggerNameContentTest.java src/test/java/hudson/plugins/emailext/plugins/recipients/DevelopersRecipientProviderTest.java src/test/java/hudson/plugins/emailext/plugins/recipients/FailingTestSuspectsRecipientProviderTest.java src/test/java/hudson/plugins/emailext/plugins/recipients/FirstFailingBuildSuspectsRecipientProviderTest.java src/test/java/hudson/plugins/emailext/plugins/recipients/MockUtilities.java src/test/java/hudson/plugins/emailext/plugins/recipients/TestUtilities.java src/test/java/hudson/plugins/emailext/plugins/trigger/BuildingTriggerTest.java src/test/java/hudson/plugins/emailext/plugins/trigger/FirstFailureTriggerTest.java src/test/java/hudson/plugins/emailext/plugins/trigger/SecondFailureTriggerTest.java src/test/java/hudson/plugins/emailext/plugins/trigger/StatusChangedTriggerTest.java src/test/java/hudson/plugins/emailext/plugins/trigger/XNthFailureTriggerTest.java src/test/java/hudson/plugins/emailext/recipients/EmailRecipientUtilsTest.java http://jenkins-ci.org/commit/email-ext-plugin/15346e064eebf1b870b01a956ff03f92655562c6 Log: [Fix JENKINS-35367] Pipeline templates (#140) new token macro version with pipeline support
          Hide
          davidvanlaatum David van Laatum added a comment -

          version 2.50 release and should be available shortly

          Show
          davidvanlaatum David van Laatum added a comment - version 2.50 release and should be available shortly
          Hide
          matthewreiter Matthew Reiter added a comment -

          Even with version 2.50 the FAILED_TESTS macro does not work in pipeline builds; it gets expanded to "FAILED_TESTS is not supported in this context". I believe the problem is that FailedTestsContent was not updated to override the new signature for evaluate() that takes a Run object as opposed to an AbstractBuild object.

          Show
          matthewreiter Matthew Reiter added a comment - Even with version 2.50 the FAILED_TESTS macro does not work in pipeline builds; it gets expanded to "FAILED_TESTS is not supported in this context". I believe the problem is that FailedTestsContent was not updated to override the new signature for evaluate() that takes a Run object as opposed to an AbstractBuild object.
          Hide
          matthewreiter Matthew Reiter added a comment -

          I've opened JENKINS-38519 for the issue with FAILED_TESTS because it's not directly related to templates.

          Show
          matthewreiter Matthew Reiter added a comment - I've opened JENKINS-38519 for the issue with FAILED_TESTS because it's not directly related to templates.
          Hide
          nikk699 Faheem Nadeem added a comment -

          Is their an example on how to use tokens?

          Show
          nikk699 Faheem Nadeem added a comment - Is their an example on how to use tokens?
          Hide
          stegeman niet niet1 added a comment -

          Thanks to the developer for making the support for the template

          Faheem Nadeem, see attachement sendMail.groovy for an example with template and tokens

          Show
          stegeman niet niet1 added a comment - Thanks to the developer for making the support for the template Faheem Nadeem , see attachement sendMail.groovy for an example with template and tokens
          Hide
          aheritier Arnaud Héritier added a comment -

          Hi David van Laatum

          It could be interesting to add sendMail.groovy in the sample directory and a link in the plugin documentation

          WDYT?

          Show
          aheritier Arnaud Héritier added a comment - Hi David van Laatum It could be interesting to add sendMail.groovy in the sample directory and a link in the plugin documentation WDYT?
          Hide
          davidvanlaatum David van Laatum added a comment -

          not exactly the best of examples eg the recipient providers could be passed directly to emailext rather than going through emailextrecipients. It also replicates much of the features of emailext

          	// Append Culprits when the build is not successfull
          	if (currentBuild.result != "SUCCESS") {
          		to << emailextrecipients([[$class: 'CulpritsRecipientProvider']])
          	}
          

          is redundant as CulpritsRecipientProvider only adds culprits to the list if the build failed.
          It also doesn't handle the body throwing an exception
          In theory this is better (untested)

          def call(body) {
              // evaluate the body block, and collect configuration into the object
              def config = [:]
              body.resolveStrategy = Closure.DELEGATE_FIRST
              body.delegate = config
              try {
                  body()
              } catch(e) {
                  currentBuild.result = "FAILURE";
                  throw e;
              } finally {
                  def subject = config.subject ? config.subject : "${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.result}!"
                  def content = '${JELLY_SCRIPT,template="static-analysis"}'
                  // Attach buildlog when the build is not successfull
                  def attachLog = (config.attachLog != null) ? config.attachLog : (currentBuild.result != "SUCCESS")
                  // Send email
                  emailext(body: content, mimeType: 'text/html',
                          replyTo: '$DEFAULT_REPLYTO', subject: subject,
                          to: config.emailRecipients, attachLog: attachLog, recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])
              }
          }
          
          Show
          davidvanlaatum David van Laatum added a comment - not exactly the best of examples eg the recipient providers could be passed directly to emailext rather than going through emailextrecipients. It also replicates much of the features of emailext // Append Culprits when the build is not successfull if (currentBuild.result != "SUCCESS" ) { to << emailextrecipients([[$class: 'CulpritsRecipientProvider' ]]) } is redundant as CulpritsRecipientProvider only adds culprits to the list if the build failed. It also doesn't handle the body throwing an exception In theory this is better (untested) def call(body) { // evaluate the body block, and collect configuration into the object def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config try { body() } catch (e) { currentBuild.result = "FAILURE" ; throw e; } finally { def subject = config.subject ? config.subject : "${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.result}!" def content = '${JELLY_SCRIPT,template= " static -analysis" }' // Attach buildlog when the build is not successfull def attachLog = (config.attachLog != null ) ? config.attachLog : (currentBuild.result != "SUCCESS" ) // Send email emailext(body: content, mimeType: 'text/html' , replyTo: '$DEFAULT_REPLYTO' , subject: subject, to: config.emailRecipients, attachLog: attachLog, recipientProviders: [[$class: 'CulpritsRecipientProvider' ], [$class: 'RequesterRecipientProvider' ]]) } }
          Hide
          aheritier Arnaud Héritier added a comment -
          Show
          aheritier Arnaud Héritier added a comment - thanks David van Laatum

            People

            • Assignee:
              davidvanlaatum David van Laatum
              Reporter:
              davidvanlaatum David van Laatum
            • Votes:
              14 Vote for this issue
              Watchers:
              25 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: