The 2 email body text can be saved as standalone ERB template files.
On Wed, Nov 04, 2020 at 06:18:02PM +0800, Luan Shengde wrote:
SendApplyAccountEmail send uuid email build email message send email send error email build error email message send error email
Signed-off-by: Luan Shengde shdluan@163.com
.../mail-robot/send-apply-account-email.rb | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 container/mail-robot/send-apply-account-email.rb
diff --git a/container/mail-robot/send-apply-account-email.rb b/container/mail-robot/send-apply-account-email.rb new file mode 100755 index 0000000..f29ff1e --- /dev/null +++ b/container/mail-robot/send-apply-account-email.rb @@ -0,0 +1,72 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+# build mail data and send mail +class SendApplyAccountEmail
- def initialize(send_mail_info)
- @send_mail_host = %x(/sbin/ip route |awk '/default/ {print $3}').chomp
- @send_mail_info = send_mail_info
- end
- def send_uuid_email
- email_msg = <<~EMAIL_MESSAGE
To: #{@send_mail_info['my_email']}
Subject: [compass-ci] Account Ready
Dear #{@send_mail_info['my_name']},
Thank you for joining us.
No indent.
You can use the following info to submit jobs:
Please make it clear which one is one-time setup.
1) setup default config
run the following command to add the below setup to default config file
blank line here
add indent only for the code block
mkdir -p ~/.config/compass-ci/defaults/
cat >> ~/.config/compass-ci/defaults/\\${USER}.yaml <<-EOF
my_email: #{@send_mail_info['my_email']}
my_name: #{@send_mail_info['my_name']}
my_uuid: #{@send_mail_info['my_uuid']}
EOF
2) download lkp-tests and dependencies
run the following command to install the lkp-test and effect the configuration
ditto
git clone https://gitee.com/wu_fengguang/lkp-tests.git
cd lkp-tests
make install
source ${HOME}/.bashrc && source ${HOME}/.bash_profile
3) submit job
reference: https://gitee.com/wu_fengguang/compass-ci/blob/master/doc/tutorial.md
find how to write job yaml
submit jobs/netperf.yaml
Please give a real example that can work.
regards
compass-ci
- EMAIL_MESSAGE
- send_mail(email_msg)
- end
- def send_error_email
- email_msg = <<~EMAIL_MESSAGE
To: #{@send_mail_info['my_email']}
Subject: apply account failed
That's not symmetric with the success email. Please add [compass-ci] prefix.
Dear #{@send_mail_info['my_name']}
Your application for account failed with following errors
#{@send_mail_info['error_message']}
The error message should be clear enough to understand the cause and tell users how to improve and avoid the error.
Thanks, Fengguang
regards
compass-ci
- EMAIL_MESSAGE
- send_mail(email_msg)
- end
- def send_mail(email_msg)
- %x(curl -XPOST "#{@send_mail_host}:#{ENV['SEND_MAIL_PORT']}/send_mail_text" -d "#{email_msg}")
- end
+end
2.23.0