##// END OF EJS Templates
Adds status option to email integration rake tasks....
Jean-Philippe Lang -
r2073:abacc2754e7a
parent child
Show More
@@ -1,105 +1,107
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 namespace :redmine do
19 19 namespace :email do
20 20
21 21 desc <<-END_DESC
22 22 Read an email from standard input.
23 23
24 24 Issue attributes control options:
25 25 project=PROJECT identifier of the target project
26 status=STATUS name of the target status
26 27 tracker=TRACKER name of the target tracker
27 28 category=CATEGORY name of the target category
28 29 priority=PRIORITY name of the target priority
29 30 allow_override=ATTRS allow email content to override attributes
30 31 specified by previous options
31 32 ATTRS is a comma separated list of attributes
32 33
33 34 Examples:
34 35 # No project specified. Emails MUST contain the 'Project' keyword:
35 36 rake redmine:email:read RAILS_ENV="production" < raw_email
36 37
37 38 # Fixed project and default tracker specified, but emails can override
38 39 # both tracker and priority attributes:
39 40 rake redmine:email:read RAILS_ENV="production" \\
40 41 project=foo \\
41 42 tracker=bug \\
42 43 allow_override=tracker,priority < raw_email
43 44 END_DESC
44 45
45 46 task :read => :environment do
46 47 options = { :issue => {} }
47 %w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
48 %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
48 49 options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
49 50
50 51 MailHandler.receive(STDIN.read, options)
51 52 end
52 53
53 54 desc <<-END_DESC
54 55 Read emails from an IMAP server.
55 56
56 57 Available IMAP options:
57 58 host=HOST IMAP server host (default: 127.0.0.1)
58 59 port=PORT IMAP server port (default: 143)
59 60 ssl=SSL Use SSL? (default: false)
60 61 username=USERNAME IMAP account
61 62 password=PASSWORD IMAP password
62 63 folder=FOLDER IMAP folder to read (default: INBOX)
63 64
64 65 Issue attributes control options:
65 66 project=PROJECT identifier of the target project
67 status=STATUS name of the target status
66 68 tracker=TRACKER name of the target tracker
67 69 category=CATEGORY name of the target category
68 70 priority=PRIORITY name of the target priority
69 71 allow_override=ATTRS allow email content to override attributes
70 72 specified by previous options
71 73 ATTRS is a comma separated list of attributes
72 74
73 75 Examples:
74 76 # No project specified. Emails MUST contain the 'Project' keyword:
75 77
76 78 rake redmine:email:receive_iamp RAILS_ENV="production" \\
77 79 host=imap.foo.bar username=redmine@example.net password=xxx
78 80
79 81
80 82 # Fixed project and default tracker specified, but emails can override
81 83 # both tracker and priority attributes:
82 84
83 85 rake redmine:email:receive_iamp RAILS_ENV="production" \\
84 86 host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\
85 87 project=foo \\
86 88 tracker=bug \\
87 89 allow_override=tracker,priority
88 90 END_DESC
89 91
90 92 task :receive_imap => :environment do
91 93 imap_options = {:host => ENV['host'],
92 94 :port => ENV['port'],
93 95 :ssl => ENV['ssl'],
94 96 :username => ENV['username'],
95 97 :password => ENV['password'],
96 98 :folder => ENV['folder']}
97 99
98 100 options = { :issue => {} }
99 %w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
101 %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
100 102 options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
101 103
102 104 Redmine::IMAP.check(imap_options, options)
103 105 end
104 106 end
105 107 end
General Comments 0
You need to be logged in to leave comments. Login now