Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HappyKit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
HappyKit
Commits
b64cb29b
Commit
b64cb29b
authored
Jul 03, 2019
by
gm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加本地缓存,记录该版本是否已经发过邮件
parent
e06cc23e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
README.md
README.md
+2
-1
notify_release_date_by_email.rb
notify_release_date_by_email.rb
+34
-9
No files found.
README.md
View file @
b64cb29b
# HappyKit
因为launchctl的运行环境所能找到的ruby为/usr/bin/ruby ruby命令必须如下方式执行
/usr/bin/ruby /Users/gm/LaunchAgentScript/HappyKit/notify_release_date_by_email.rb
notify_release_date_by_email.rb
View file @
b64cb29b
#!/usr/bin/ruby
# encoding: UTF-8
require
'httparty'
require
"ostruct"
require
'mail'
...
...
@@ -43,6 +44,7 @@ def login
end
def
today
# 打开下面注释,改成某个版本开始时间,就可以调试这个版本的发邮件服务了
# return Date.parse("2019-06-20")
return
Date
.
today
end
...
...
@@ -90,14 +92,30 @@ end
def
should_send_email_today
response
=
get_dev_events_response
obj
=
JSON
.
parse
(
response
.
body
,
object_class:
OpenStruct
)
# 读取历史记录,如果以前发送过,则不需要再次发送
filePath
=
File
.
dirname
(
__FILE__
)
+
'/sprintEmailHistory.log'
file
=
File
.
open
(
filePath
,
"a+"
,
external_encoding:
Encoding
::
UTF_8
,
internal_encoding:
Encoding
::
UTF_8
)
history
=
file
.
read
()
puts
"history
#{
history
}
"
for
event
in
obj
.
events
puts
"
#{
event
.
title
}
#{
event
.
start
}
"
start
=
Date
.
parse
(
event
.
start
)
if
start
==
today
return
true
if
start
==
today
if
history
==
event
.
title
puts
"
#{
event
.
title
}
版本已经发过邮件"
return
false
else
file
.
truncate
(
0
)
count
=
file
.
write
(
event
.
title
)
file
.
close
puts
"可以发送邮件"
return
true
end
end
end
puts
"今天不是发送邮件的日子"
return
false
end
...
...
@@ -119,10 +137,19 @@ def send_email(deliver_info)
mail
=
Mail
.
deliver
do
# 其实下面都是方法调用,不要被迷惑了
to
[
'hualu@igengmei.com'
,
'wangjun@igengmei.com'
,
'sunwenhui@igengmei.com'
,
'tanchenshuai@igengmei.com'
,
'zhucuicui@igengmei.com'
,
'huchunhe@igengmei.com'
,
'dongqiang@igengmei.com'
,
'SJ-liuxiao@igengmei.com'
,
'client-rd@igengmei.com'
]
#to ['jaguar@igengmei.com']
from
'jaguar@igengmei.com'
# to ['jaguar@igengmei.com']
bcc
'jaguar@igengmei.com'
# 抄送
from
'jaguar@igengmei.com'
# 发件人
subject
"更美app
#{
deliver_info
.
title
}
商店物料信息"
body
"Hi,All,
#{
deliver_info
.
title
}
时间为
#{
deliver_info
.
date
.
to_s
}
,请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~"
text_part
do
content_type
"text/plain; charset=utf-8"
body
<<-
EOF
Hi,All
#{
deliver_info
.
title
}
时间为
#{
deliver_info
.
date
.
to_s
}
,请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF
end
end
end
...
...
@@ -144,7 +171,5 @@ if should_send_email_today
false
)
DingBot
.
send_msg
(
message
)
end
else
puts
"今天不是发邮件日期"
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment