Redmine Gmail imap Rake script

Hi,

I am new to Redmine, I am using Gmail for outbound email notifications and all is working Fine.

However I cannot get my head around the rake command to fetch emails from Gmail.

I have seen many examples but even cutting and pasting but modifying them still does work, I think the issue is with me and not grasping the rake command, I am using ubuntu Bitnami 14.04 virtual machine.

Can you clarify the structure of this command so I can test it.

/opt/bitnami/apps/redmine/htdocs/bin/rake I can see this is a valid path is this the rake program?

What is this section

-f /opt/bitnami/apps/redmine/htdocs/Rakefile there is no Rakefile so I created one using nano

Should the rakefile contain this redmine:email:receive_imap RAILS_ENV=“production” host=imap.gmail.com port=993 ssl=1 username=xxx@gmail.com password=xxx project=vod835 tracker=errore allow_override=tracker,priority unknown_user=accept no_permission_check=1 ?

When I run this command on the console I get syntax error, unexpected “:” expecting end of input redmine:email:^receive_imap.

I added teh --trace command to the end

I have spend a considerable length of time looking for a solution but I believe that I am doing something wrong and the software is working fine.

Any pointers in this matter would be very helpful

Regards

Steve

Hi @steve_smith,

I’ve tried to reproduce the issue in a Redmine 3.3.1-0 virtual machine, but the /opt/bitnami/apps/redmine/htdocs/Rakefile is present. You shouldn’t have to create a Rakefile.

Can you give us more information about the version of the virtual machine you’re running and any additional steps you may have followed after starting the virtual machine?

Thank you for your kind cooperation.

Best regards,
Alvaro Recio

HI Alvaro

Sorry for the delay in getting back to you.

ubuntu 14.04 kernel 3.13.0
I think the problem is a lack of knowledge on how to get the string into a cronjob

I am using Gmail to send emails and this is working fine.

So I literally took the string that was on the forum changed the gmail details and ran it on the console and I would get the errors that I indicated in the original… I am not sure what I am doing wrong

So I took this code

*/30 * * * * redmineuser rake -f /path/to/redmine/appdir/Rakefile redmine:email:receive_imap RAILS_ENV=“production” host=imap.gmail.com username=xxx@gmail.com password=xxx

I left the redmine user out, do I need to have a dedicated account for this to run.

Regards

Steve

Hi Alvaro,

I can see the Rakefile in the location mentioned, I modified the command to this

rake -f /opt/bitnami/apps/redmine/htdocs/Rakefile redmine:email:receive_imap RAILS_ENV=“production” host=imap.gmail.com username=xxx@gmail.com password=xxxx I now have a different error,

Do I need to upgrade rake?

Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 11.3.0. Prepending bundle exec to your command may solve this.
/opt/bitnami/apps/redmine/htdocs/config/boot.rb:4:in <top (required)>' /opt/bitnami/apps/redmine/htdocs/config/application.rb:1:in <top (required)>’
/opt/bitnami/apps/redmine/htdocs/Rakefile:5:in <top (required)>' LoadError: cannot load such file -- bundler/setup /opt/bitnami/apps/redmine/htdocs/config/boot.rb:4:in <top (required)>’
/opt/bitnami/apps/redmine/htdocs/config/application.rb:1:in <top (required)>' /opt/bitnami/apps/redmine/htdocs/Rakefile:5:in <top (required)>’
(See full trace by running task with --trace)

Your issue is quite similar to mine awhile back. Try my solution at: Create update new issues via email and see if that works for you.

Hi @steve_smith,

Could you try the solution provided by @wthsia and confirm whether it works for you or not?

Best regards,
Alvaro Recio

HI, Slowly making progress,

New issue

I created what I believe to be a script based on wthsia information,

Please see below the script and the latest error

.sh file

#!/bin/sh

PATH="/opt/bitnami/perl/bin:/opt/bitnami/git/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/ruby/bin:/opt/bitnami/subversion/bin:/opt/bitnami/postgresql/bin:/opt/bitnami/php$
BITNAMI_ROOT="/opt/bitnami"
export BITNAMI_ROOT

cd /opt/bitnami/apps/redmine/htdocs/

bundle exec rake -f Rakefile redmine:email:receive_imap port=993 RAILS_ENV=“production” host=imap.gmail.com username=xxxxxx@gmail.com password=xxxx ssl=true project=domain tracker=Support unknown_user=create.


run ./getmail.sh

Now get this made sure that I had chmod 666 the .sh file as it initially would not run

rake aborted!
Psych::SyntaxError: (): did not find expected key while parsing a block mapping at line 16 column 5
/opt/bitnami/apps/redmine/htdocs/lib/redmine/configuration.rb:86:in load_from_yaml' /opt/bitnami/apps/redmine/htdocs/lib/redmine/configuration.rb:42:in load’
/opt/bitnami/apps/redmine/htdocs/lib/redmine/configuration.rb:67:in []' /opt/bitnami/apps/redmine/htdocs/lib/redmine/thumbnail.rb:25:in module:Thumbnail
/opt/bitnami/apps/redmine/htdocs/lib/redmine/thumbnail.rb:22:in <module:Redmine>' /opt/bitnami/apps/redmine/htdocs/lib/redmine/thumbnail.rb:21:in <top (required)>’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in block in require’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in load_dependency' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require’
/opt/bitnami/apps/redmine/htdocs/lib/redmine.rb:48:in <top (required)>' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in block in require' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in load_dependency’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require' /opt/bitnami/apps/redmine/htdocs/config/initializers/30-redmine.rb:6:in <top (required)>’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in load' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in block in load’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in load_dependency' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in load’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/engine.rb:652:in block in load_config_initializer' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in instrument’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/engine.rb:651:in load_config_initializer' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/engine.rb:616:in block (2 levels) in class:Engine
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in each' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in block in class:Engine
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in instance_exec' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in run’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in block in run_initializers' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in each’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in tsort_each_child' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in run_initializers’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/application.rb:352:in initialize!' /opt/bitnami/apps/redmine/htdocs/config/environment.rb:14:in <top (required)>’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in block in require’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in load_dependency' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in require’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/application.rb:328:in require_environment!' /opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/railties-4.2.7.1/lib/rails/application.rb:457:in block in run_tasks_blocks’
/opt/bitnami/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>’
Tasks: TOP => redmine:email:receive_imap => environment
(See full trace by running task with --trace)

try running the bundle exec command manually. So run “./use_redmine” to get a subshell. navigate to apps/redmine/htdocs/ and runt he bundle exec command with --trace. That may give you more info to troubleshoot.

Hi,

I have tried the command that you suggested, however I am still getting this error with the --trace what code block mapping line 17 column 5 is this referring to

rake aborted!
Psych::SyntaxError: (): did not find expected key while parsing a block mapping at line 17 column 5

Hello @steve_smith,

Could you also check the YAML configuration file syntax? According to the error message, it seems it is a syntax error. Yaml files are very picky regarding tab and spaces characters. You can use a tool like http://www.yamllint.com/ to validate the syntax.

Regards,
Tomas

Thank you for your help,

I started with a Fresh VM and followed the same steps and used the same code and it is all working now, so I am not sure what I was doing incorrectly.

I just now need to figure out the layout to raise bugs etc from the email import for each project,

It seems to work well when replying to comments, am I correct in thinking that a user can email bugs directly to a project. Time for some more reading thanks again for your help.

Steve
.

Hi @steve_smith,

We are glad that you were able to fix the issue. Thanks to @wthsia for your help too, we appreciate it.

If you have any other question and you think we can help, please don’t hesitate to ask.

Best regards,
Alvaro Recio