I am currently trying to understand why Jenkins is not sending emails.
The expected behavior is, that Jenkins will send emails to the whole team if the master branch is broken. If a feature branch breaks a email to the person who broke it, should be send.
Emails for the master branch are working, but not for broken feature branches.We are using the email-ext plugin. If you take a look at the code below you will see that the getEMailRecipients function will return an empty string for feature branches.
Docs example
In the docs an example is given that should
Send an email to abc plus any addresses returned by the providers
emailext (
body: 'A Test EMail',
recipientProviders: [
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
subject: 'Test',
to: 'abc'
)
My understanding of this example is, that an email should be send even if the to property is empty.
Property value docs
The docs for the plugin state the following for the 'CulpritsRecipientProvider' option
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.
My Code
Helper functions:
def getTeamRecipients() {
return 'name1 name2 nameX'
}
def getEMailRecipients(currentBranch) {
return (currentBranch.toLowerCase().contains("current") ||
currentBranch.toLowerCase().contains("master")) ?
getTeamRecipients() :
""
}
def sendEMail(recipients) {
emailext (
to: recipients,
subject: "Job '${env.JOB_NAME}' is in state ${currentBuild.currentResult}",
body: "See ${env.BUILD_URL} for more details",
recipientProviders: [
[$class: 'CulpritsRecipientProvider'],
]
)
}
Email Send part:
if (currentBuild.currentResult == "FAILURE") {
def recipients = getEMailRecipients("$BRANCH_NAME")
sendEMail(recipients)
}
Does anyone have an idea what is wrong with my build script code?
Related
Brand new to Jenkins so forgive any noob errors. I have a Pipeline with this code:
pipeline {
agent any
stages {
stage('Ok') {
steps {
echo "Ok"
}
}
}
post {
always {
emailext (
subject:'Jenkins Build Test for XUSDK',
mimeType: 'text/html',
to: 'testuser#example.com',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],[$class: 'RequesterRecipientProvider']],
body: 'Testing Jenkins sending an email message after building a job.'
)
}
}
}
This works fine and sends an email to the recipient in the to field. However, if I change that value to:
to:'testuser'#example.com','testuser2#example.com',
The build fails and I receive this error:
WorkflowScript: 14: Arguments to "emailext" must be explicitly named. # line 14, column 11.
emailext (
My Google-fu failed and I was not able to find a solution. Checking SO, other answers have indicated this is the proper way to send email to more than one recipient. Any help would be appreciated.
Use the below:-
to:'testuser#example.com,testuser2#example.com'
I created a module in which I am displaying all the dormant users by combining two tables - customer and order table and now I Want to perform bulk action (mail send action ) to the dormant users , But I want to make a email template in which this template can be edited and used for sending email to the dormant users from the BO.
How to send email using a template in prestashop ? .
I created a email template (created.html and .text file ) in email folder, Also edited classes/Langugae.php
// Added natives mails files
$mFiles = array(
'account.html', 'account.txt',
'backoffice_order.html', 'backoffice_order.txt',
'bankwire.html', 'bankwire.txt',
'cheque.html', 'cheque.txt',
'contact.html', 'contact.txt',
'contact_form.html', 'contact_form.txt',
'credit_slip.html', 'credit_slip.txt',
'download_product.html', 'download_product.txt',
'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt',
'guest_to_customer.html', 'guest_to_customer.txt',
'in_transit.html', 'in_transit.txt',
'log_alert.html', 'log_alert.txt',
'newsletter.html', 'newsletter.txt',
'order_canceled.html', 'order_canceled.txt',
'order_conf.html', 'order_conf.txt',
'order_customer_comment.html', 'order_customer_comment.txt',
'order_merchant_comment.html', 'order_merchant_comment.txt',
'order_return_state.html', 'order_return_state.txt',
'outofstock.html', 'outofstock.txt',
'password.html', 'password.txt',
'password_query.html', 'password_query.txt',
'payment.html', 'payment.txt',
'payment_error.html', 'payment_error.txt',
'preparation.html', 'preparation.txt',
'refund.html', 'refund.txt',
'reply_msg.html', 'reply_msg.txt',
'shipped.html', 'shipped.txt',
'test.html', 'test.txt',
'voucher.html', 'voucher.txt',
'voucher_new.html', 'voucher_new.txt',
'order_changed.html', 'order_changed.txt',
'dormant_email.html', 'dormant_email.txt'
);
I added my email template - 'dormant_email.html', 'dormant_email.txt' in mails\en folder
ok I solved this by adding the template file by creating mail.en folder in module folder ( modulename/emails/en/)
and by below code
if (!Mail::Send(
$this->context->language->id,
'dormant_email',
Mail::l('Hello Long Time No See ! Please Visit and Get a Chance to Win'),
$templateVars,
$dormantUserEmailID,
null, null, null, null, null, dirname(__FILE__).'/mails/', true, $this->context->shop->id))
die('0') ;echo "<script type=\"text/javascript\">alert('Email Send');</script>"; return true;
die('1');echo "<script type=\"text/javascript\">alert('Email not Send');</script>"; return false;
I am able to send email and use the template and it is been listing when I click on the
Localization->transalations -->modify transalations
select email template translations and select English and click modify button and in the modules when u expand your module the email template can be seen and can be edited by edit tool .
I'm trying to send emails using Serilog.Sinks.Email NuGet package (v1.5.0.0) with the Mandrill SMTP service. The following code executes but does not send any emails. When I try and use the same credentials using the System.Net.Mail.SmtpClient, it works and send an email.
EmailConnectionInfo info = new EmailConnectionInfo()
{
EmailSubject = "Email subject",
FromEmail = "from#gmail.com",
MailServer = "smtp.mandrillapp.com",
NetworkCredentials = new NetworkCredential("mandrill_username", "mandrill_apikey"),
Port = 587,
ToEmail = "to#gmail.com"
};
Log.Logger = new LoggerConfiguration()
.WriteTo.Email(info)
.CreateLogger();
Log.Error("Houston we have a problem");
As you spotted, this was a bug in the latest build of the Email sink, which your graciously-provided pull request has fixed. Version 1.5.13 of the sink, now on NuGet, includes the fix.
When sending an email from C# with body being large is resulting in failure in sending email
Mailbox unavailable.
The email is working fine with a smaller body. I am using html body to true property..
Thanks,
Zafar
Code:
using (MailMessage _mailMsg = new MailMessage())
{
_mailMsg.From = new MailAddress(ConfigurationManager.AppSettings["mailFrom"].ToString());
_mailMsg.Body = mail.Body;
_mailMsg.Subject = mail.Subject;
_mailMsg.IsBodyHtml = true;
foreach (string strEmailIds in mailTo)
{
if (strEmailIds != null && strEmailIds != string.Empty && strEmailIds != "")
{
if (!_mailMsg.To.Contains(new MailAddress(strEmailIds)))
_mailMsg.To.Add(new MailAddress(strEmailIds));
}
}
//_mailMsg.CC.Add(ConfigurationManager.AppSettings["mailCC"].ToString());
using (SmtpClient _client = new SmtpClient(ConfigurationManager.AppSettings["Host"].ToString()))
{
if (_mailMsg.To.Count > 0)
{
_client.Send(_mailMsg);
}
else
{
_mailMsg.Subject = "No emails associated with the portfolio: " + account + " Original Email:" + mail.Subject;
_mailMsg.To.Add(new MailAddress(ConfigurationManager.AppSettings["mailSuppotTeam"].ToString()));
_client.Send(_mailMsg);
}
Oke, on thing it could be is that the mail server rejects big messages. Let exclude that one... I assume you have a local smtp mail server installed (check for telnet 127.0.0.1 25 that should give a sort of reply) configure the mail server [ConfigurationManager.AppSettings["Host"]] for 127.0.0.1, can you send big mails now?
If ConfigurationManager.AppSettings["Host"] is already the local SMTP server then:
a) stop that smtp service (Simple Mail Transfer Protocol) for a moment (via the command services.msc)
b) send a small email
c) go to c:\inetpub\mailroot\pickup and edit the message via notepad so that it becomes a BIG email
d) start the smtp service again (services.msc)
The issue was with sending email to cross domain email id and was resulting in the Generic exception
"Mailbox unavailable." May be this is one of the reason behind the above exception.
I am trying to send emails from hyperion servers when the number of records is 0.I am writing the script code in onPostProcess().
var dtm_current = new Date();
Application.ExecuteBScript("Set BrioQuery, Mail, 'Internet Mail', mailserverwithoutquotes,fromid'"); //note that mailserver name is given without quotes and
//from id does nt have starting quote
Application.ExecuteBScript("Export Section Root.'Results', OfficeMHTML, 'job_output', Silent, email, 'Testing Email action', 'This is a test of the email action. \n\n\n', UTF-8, To, tomailid'");
Console.Writeln ( "Post Process Script complete:"+dtm_current );
I am getting the error
Emailing section 'Results' as 'Microsoft Office Web Archive' to:
com'
Export failed. Error: Connection failed to locate host, 127.0.0.1. Is the SMTP server on port 25? (Errcode=146)
Question I have : Why it is trying to connect to localhost instead of specified email server
I have got this working.
var dtm_current = new Date();
Application.ExecuteBScript("Set BrioQuery, Mail, 'Internet Mail', emailserverwithoutquotes,'fromemailid'");
var count =1* ActiveDocument.Sections['R-Results'].RowCount;
Console.Writeln(count);
if(count > 0){
Application.ExecuteBScript("Export Section Root.'R-Results', csv, 'job_output', Silent, email, 'Testing Email action if', 'This is a test of the email action if. \n\n\n', UTF-8, To, 'tomailid'");
}
else{
Application.ExecuteBScript("Export Section Root.'R-Results', csv, 'job_output', Silent, email, 'Testing Email action else', 'This is a test of the email action else. \n\n\n', UTF-8, To, 'tomailid'");
}