hi all , I want to be able to send mails from a Pipeline Job on Jenkins... here what I done and do not work --- I installed the Email Extension Plugin (2.66) for Jenkins (2.176.3) to use in Pipelines and I'm trying the example on: https://medium.com/@gustavo.guss/jenkins-sending-email-on-post-build-938b236545d2
pipeline { environment { //This variable need be tested as string doError = '1' } agent any stages { stage('Error') { when { expression { doError == '1' } } steps { echo "Failure" error "failure test. It's work" } } stage('Success') { when { expression { doError == '0' } } steps { echo "ok" } } } post { always { echo 'I will always say Hello again!' emailext body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}" } } } But I have the following error : Error when executing always post condition: java.lang.NoSuchMethodError: No such DSL method 'emailext' found among steps [VersionNumber, acceptGitLabMR, addGitLabMRComment, archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, envVarsForTool, error, fileExists, findFiles, getContext, ... Also I cannot configure the plugin itself and I do not know how to activate it, I restarted Jenkins, the system and did not work , the pipeline syntax editor does not recognize the plugin, any suggestions ? I posted the same question on stackoverflow ... https://stackoverflow.com/questions/58031972/email-plugin-on-jenkins-pipelines Also I try with an simple pipeline job that should send a mail (I guess it is with the default Mail plugin ), I configured on Manage jenkins -> Configure System with port 465 and the appropriated SMTP server , when I test the configuration by sending an e-mail , it sends and I can see the test mail on my inbox , but from the pipeline job , it fails: ``` node { stage("test") { def message = "hello there!" mail bcc: '', body: message, cc: '', from: 'a...@mycom.com', replyTo: ' jenkinsu...@mycom.com', subject: "Develop: build generated ", to:'gr...@mycom.com' } } ``` Error: ``` java.net.SocketException: Connection closed by remote host at sun.security.ssl.SSLSocketImpl.checkWrite(Unknown Source) at sun.security.ssl.AppOutputStream.write(Unknown Source) at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:114) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.flush(Unknown Source) at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2104) Caused: javax.mail.MessagingException: Can't send command to SMTP host; nested exception is: java.net.SocketException: Connection closed by remote host at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2106) at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2093) at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:1184) ``` Any suggestion how to fix it? thanks, -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/82792797-a4e5-444c-b5e8-5741448fed69%40googlegroups.com.