sample: mail-job crystal.92144 Date: Mon, Oct 12 2020 17:30:56PM +0800 From: team@crystal.ci To: lwt@crystal.ci Subject: [Compass-ci] job: crystal.92144 result
Hi, Thanks for your participation in Kunpeng and software ecosystem! Your Job: crystal.92144 had finished. Please check job result: http://172.17.0.1:11300/result/iperf/vm-hi1620-2p8g--lwt/2020-10-12/crystal....
Regards Compass-ci https://gitee.com/openeuler/compass-ci
Signed-off-by: Lu Weitao luweitaobe@163.com --- lib/constants.rb | 5 ++++- lib/mail_job_result.rb | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/constants.rb b/lib/constants.rb index 3a4f083..3d1ef1d 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -9,4 +9,7 @@ ES_HOST = config['ES_HOST'] || '172.17.0.1' ES_PORT = config['ES_PORT'] || 9200
MAIL_HOST = config['MAIL_HOST'] || '172.17.0.1' -MAIL_PORT = config['MAIL_PORT'] || 11_311 +MAIL_PORT = config['MAIL_PORT'] || 11311 + +SRV_HTTP_HOST = config['SRV_HTTP_HOST'] || ENV['SRV_HTTP_HOST'] || '172.17.0.1' +SRV_HTTP_PORT = config['SRV_HTTP_PORT'] || ENV['SRV_HTTP_PORT'] || 11300 diff --git a/lib/mail_job_result.rb b/lib/mail_job_result.rb index 9202b81..29a9c1a 100644 --- a/lib/mail_job_result.rb +++ b/lib/mail_job_result.rb @@ -9,8 +9,10 @@ require 'json'
# compose and send email for job result class MailJobResult - def initialize(job_id) + def initialize(job_id, result_host = SRV_HTTP_HOST, result_port = SRV_HTTP_PORT) @job_id = job_id + @result_host = result_host + @result_port = result_port end
def send_mail @@ -25,7 +27,7 @@ class MailJobResult body = "Hi, Thanks for your participation in Kunpeng and software ecosystem! Your Job: #{@job_id} had finished. - Please check job result: \n\n#{signature}" + Please check job result: http://#%7B@result_host%7D:#%7B@result_port%7D#%7B@result_root%7D%5Cn%5Cn#%7..." { 'to' => @submitter_email, 'body' => body, 'subject' => subject } end
@@ -34,6 +36,7 @@ class MailJobResult exit unless job['email']
@submitter_email = job['email'] + @result_root = job['result_root'] end
def query_job