import atexit
import shutil
import logging
-import smtplib
import optparse
import datetime
import platform
JOB_NAME = os.environ.get('JOB_NAME')
GIT_COMMITTER_EMAIL = os.environ.get('GIT_COMMITTER_EMAIL')
-SMTP_SERVER = 'roma.profitbricks.localdomain'
-SMTP_SUBJECT = 'Build for job %s, branch %s, buildnumber %s was %s'
-SMTP_TEXT = (
- 'Build for job %s, branch %s, buildnumber %s was %s. ' +
- 'Take a close look at: ' + BUILD_URL
-)
-SMTP_BUILD_SUCCESS = 'SUCCESSFUL'
-SMTP_BUILD_ERROR = 'NOT SUCCESSFUL'
-SMTP_FROM = '%s@profitbricks.com' %(pwd.getpwuid(os.geteuid()).pw_name)
DPUT_OPTIONS = {
'fqdn': 'alexandria.profitbricks.localdomain',
print '##########################################################################'
print '##########################################################################'
-def send_email(result):
- smtp = smtplib.SMTP(SMTP_SERVER)
- if result == SMTP_BUILD_ERROR:
- global SMTP_TEXT
- SMTP_TEXT += '\nThe filesystem path is: %s' %(GIT_TARGET_WORKSPACE)
- msg = (
- 'From: %s\n' %(SMTP_FROM) +
- 'To: %s\n' %(GIT_COMMITTER_EMAIL) +
- 'Subject: %s\n' %(SMTP_SUBJECT %(JOB_NAME, GIT_DEBIAN_BRANCH, BUILD_NUMBER,
- result)) +
- '%s\n' %(SMTP_TEXT %(JOB_NAME, GIT_DEBIAN_BRANCH, BUILD_NUMBER, result))
- )
- logger.info('Sending this message: %s', msg)
- smtp.sendmail(SMTP_FROM, GIT_COMMITTER_EMAIL, msg)
- smtp.quit()
-
def read_file(path):
try:
fh = open(path, 'r', 1)
def exit_ok():
- send_email(SMTP_BUILD_SUCCESS)
sys.exit(0)
def exit_error():
sys.exitfunc = lambda: None
- send_email(SMTP_BUILD_ERROR)
sys.exit(1)
def getopts():
import shutil
import subprocess
import logging
-import smtplib
from glob import glob
from logging import Formatter
import kernel_persistence
GIT_COMMITTER_EMAIL = os.environ.get('GIT_COMMITTER_EMAIL')
-SMTP_SERVER = 'roma.profitbricks.localdomain'
-SMTP_SUBJECT = 'Kernel build for branch %s, buildnumber %s was %s'
-SMTP_TEXT = (
- 'Kernel build for branch %s, buildnumber %s was %s. ' +
- 'Take a close look at: ' + BUILD_URL
-)
-SMTP_BUILD_SUCCESS = 'SUCCESSFUL'
-SMTP_BUILD_ERROR = 'NOT SUCCESSFUL'
-SMTP_FROM = 'jenkins@profitbricks.com'
PBUILDER = '/usr/sbin/pbuilder'
SUDO = '/usr/bin/sudo'
logger.addHandler(stream_handler)
-def send_email(result):
- smtp = smtplib.SMTP(SMTP_SERVER)
- msg = (
- 'From: %s\n' %(SMTP_FROM) +
- 'To: %s\n' %(GIT_COMMITTER_EMAIL) +
- 'Subject: %s\n' %(SMTP_SUBJECT %(GIT_BRANCH_NAME, BUILD_NUMBER,
- result)) +
- '%s\n' %(SMTP_TEXT %(GIT_BRANCH_NAME, BUILD_NUMBER, result))
- )
- smtp.sendmail(SMTP_FROM, GIT_COMMITTER_EMAIL, msg)
- smtp.quit()
-
def build_kernel_with_pbuilder(revision, pbuilder_script, dist='stable'):
pbuilder_script = os.path.abspath(pbuilder_script)
logger.info('deleted %s' %(rmpath))
def exit_ok():
- send_email(SMTP_BUILD_SUCCESS)
sys.exit(0)
def exit_error():
- send_email(SMTP_BUILD_ERROR)
sys.exit(1)
if __name__ == '__main__':