Skip to contentSkip to conversation

SendQAEmail.py: use sendmail instead of mail to send QA email

PATCH Applied Bill Randle 2 participants 2 messages Aug 9, 2016 – Aug 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SendQAEmail.py: use sendmail instead of mail to send QA email

When sending QA emails, the autobuilder uses the 'mail' command (typically installed as /usr/bin/mail or /bin/mail). However, most distributions do not install this program by default. They generally always install the 'sendmail' program, though, so use 'sendmail' as the mail agent, rather than 'mail'.

[YOCTO #10082]

---
 .../autobuilder/buildsteps/SendQAEmail.py          | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)
lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py +14 -12
index 0cd76d5..3691cc6 100644
@@ -47,9 +47,9 @@ class SendQAEmail(ShellCommand):
             properties = self.build.getProperties().asDict()
             repoprops = {}
             mailsubject = "Build available for QA"
-            email_header = '''
-    A build identified as needing QA has finished on the autobuilder. This
-    build is located at:\n\n
+            email_base = '''
+A build identified as needing QA has finished on the autobuilder. This
+build is located at:\n\n
     %s''' % (self.getProperty('DEST').replace(web_root, web_url))
 
             if str(self.getProperty("custom_release_me")) == "True":
@@ -68,9 +68,9 @@ class SendQAEmail(ShellCommand):
                 poky_number = self.getProperty("custom_poky_number")+prefix
                 yocto_number = self.getProperty("custom_yocto_number")+prefix
                 rel_name = 'yocto-'+ yocto_number
-                email_header = '''
+                email_base = '''
 A release candidate build for %s is now available at:\n\n
-%s\n\n
+    %s\n\n
 Please begin QA on this build as soon as possible.''' % (rel_name, self.getProperty('DEST').replace(web_root, web_url))
                 mailsubject = "Release Candidate Build for " + rel_name + snapshot + " now available."
 
@@ -85,16 +85,18 @@ Please begin QA on this build as soon as possible.''' % (rel_name, self.getPrope
             for k, v in repoprops.iteritems():
                 email_body = email_body + '%s : %s \n' % (k, v[1])
 
-            mailcmd = 'echo -e "' + email_header + '\n' + email_body + '\n' + mailsig + ' " | mail -s \'' + mailsubject + '\''
-
+            email_header = ""
+            if mailto is not None and mailto is not "":
+                email_header += "To: " + mailto + "\n"
             if mailcc is not None and mailcc is not "":
-                mailcmd += " -c '" + mailcc + "' "
-
+                email_header += "Cc: " + mailcc + "\n"
             if mailbcc is not None and mailbcc is not "":
-                mailcmd += " -b '" + mailbcc + "' "
+                email_header += "Bcc: " + mailbcc + "\n"
+
+            email_header += "Subject: " + mailsubject + "\n"
+
+            mailcmd = 'echo -e "' + email_header + "\n" + email_base + '\n' + email_body + '\n' + mailsig + ' " | sendmail -t'
 
-            if mailto is not None and mailto is not "":
-                mailcmd += " '" + mailto + "' "
             self.command = mailcmd
         else:
             self.command = 'echo "Not a QA build"'
Signature · 1 line
2.5.5
#1 lore raw

Merged into master,

Thanks
-b

Quoted 85 lines · Bill Randle

When sending QA emails, the autobuilder uses the 'mail' command (typically
installed as /usr/bin/mail or /bin/mail). However, most distributions do not
install this program by default. They generally always install the 'sendmail'
program, though, so use 'sendmail' as the mail agent, rather than 'mail'.

[YOCTO #10082]

---
 .../autobuilder/buildsteps/SendQAEmail.py          | 26
++++++++++++----------

 1 file changed, 14 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

packages/autobuilder/buildsteps/SendQAEmail.py b/lib/python2.7/site- packages/autobuilder/buildsteps/SendQAEmail.py
index 0cd76d5..3691cc6 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/SendQAEmail.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/SendQAEmail.py

lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py +0 -0
@@ -47,9 +47,9 @@ class SendQAEmail(ShellCommand):
              properties = self.build.getProperties().asDict()
              repoprops = {}

             mailsubject = "Build available for QA"
-            email_header = '''
-    A build identified as needing QA has finished on the autobuilder. This
-    build is located at:\n\n
+            email_base = '''
+A build identified as needing QA has finished on the autobuilder. This
+build is located at:\n\n
     %s''' % (self.getProperty('DEST').replace(web_root, web_url))
             if str(self.getProperty("custom_release_me")) == "True":

(quoted diff) +0 -0
@@ -68,9 +68,9 @@ class SendQAEmail(ShellCommand):

                 poky_number = self.getProperty("custom_poky_number")+prefix yocto_number = self.getProperty("custom_yocto_number")+prefix
                 rel_name = 'yocto-'+ yocto_number
-                email_header = '''
+                email_base = '''
 A release candidate build for %s is now available at:\n\n -%s\n\n
+    %s\n\n
 Please begin QA on this build as soon as possible.''' % (rel_name, self.getProperty('DEST').replace(web_root, web_url)) mailsubject = "Release Candidate Build for " + rel_name + snapshot + " now available."

(quoted diff) +0 -0
@@ -85,16 +85,18 @@ Please begin QA on this build as soon as

possible.''' % (rel_name, self.getPrope
             for k, v in repoprops.iteritems():
                 email_body = email_body + '%s : %s \n' % (k, v[1])
-            mailcmd = 'echo -e "' + email_header + '\n' + email_body
+ '\n' + mailsig + ' " | mail -s \'' + mailsubject + '\'' -
+            email_header = ""
+            if mailto is not None and mailto is not "":
+                email_header += "To: " + mailto + "\n"
             if mailcc is not None and mailcc is not "":
-                mailcmd += " -c '" + mailcc + "' "
-
+                email_header += "Cc: " + mailcc + "\n"
             if mailbcc is not None and mailbcc is not "":
-                mailcmd += " -b '" + mailbcc + "' "
+                email_header += "Bcc: " + mailbcc + "\n"

lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py +5 -0
+
+            email_header += "Subject: " + mailsubject + "\n"
+
+            mailcmd = 'echo -e "' + email_header + "\n" + email_base
+ '\n' + email_body + '\n' + mailsig + ' " | sendmail -t'


-            if mailto is not None and mailto is not "":
-                mailcmd += " '" + mailto + "' " self.command = mailcmd
         else:
             self.command = 'echo "Not a QA build"'