Control Redmine from the command line
Added by Dave Nolan over 15 years ago
Hello,
I've written a script to control Redmine from the command line. The original blog post is here http://textgoeshere.org.uk/articles/2009/03/control-redmine-from-the-command-line/. You can get the script here http://github.com/textgoeshere.org.uk/redcmd.
Suggestions, bugs, etc. all welcome. Hope you find it useful!
Cheers,
Dave
Replies (11)
RE: Control Redmine from the command line - Added by Dave Nolan over 15 years ago
Doh, that second url should be http://github.com/textgoeshere/redcmd.
RE: Control Redmine from the command line - Added by Paul Hinze over 15 years ago
I've had this on my TODO list forever, and I've played around with a couple of different iterations of how to do it.
See http://github.com/phinze/libredmine/tree/master
Nice to see someone else interested in the same thing. Maybe we can work together!
My biggest concern is having to use mechanize as a backend, which is so clunky and tightly couples with things it shouldn't be (it's the same way my code works, though). I started to envision this intermediary layer with objects in the command line program mirroring remote objects in Redmine (you'll see that in the 'libredmine' portion of my project), but that led me to just wanting to be able to interface w/ Redmine in a cleaner way like with a webservice or something. I feel guilty just essentially duplicating redmine's models manually.
Anyways, I'm curious to hear your thoughts and excited to build something useful!
RE: Control Redmine from the command line - Added by Dave Nolan over 15 years ago
Hey Paul,
Great minds think alike then?
I think your advanced approach is interesting, and I agree using Mechanize is a bit hacky.
In my opinion, what we really need is a REST-ful API. I think there is work going around this http://www.redmine.org/issues/show/296. Perhaps that's where we should devote our energy. What do you reckon?
Dave
RE: Control Redmine from the command line - Added by Eric Davis over 15 years ago
I'm planning on working on the REST API (sometime soon) and would love any help or patches (#296). Once there is the API, you can probably use something like rest client for a simple command line access.
Eric
RE: Control Redmine from the command line - Added by Dave Nolan over 15 years ago
Eric Davis wrote:
I'm planning on working on the REST API (sometime soon) and would love any help or patches (#296). Once there is the API, you can probably use something like rest client for a simple command line access.
Eric
Yes, definitely the way forward. In the meantime, though, feel free to use my script :)
RE: Control Redmine from the command line - Added by Christian Ribe about 15 years ago
Could someone help me?
I don't know how to install redcmd (I'm new to all of this).
Where do I install red.rb?
How do I use it from the bitnami redmine stack?
Thanks
RE: Control Redmine from the command line - Added by Christian Ribe about 15 years ago
Bump....anyone? :(
RE: Control Redmine from the command line - Added by Dave Nolan about 15 years ago
Hey,
It's meant to be called from the command line directly.
On windows, you could hack up a BAT to run it.
ruby "%~dp0red.rb" %*
On *nix, you add this as the first line of red.rb:
#!/usr/bin/env ruby
Remember to chmod a+x red.rb
to allow it to be run as a script.
I recommend adding the folder red.rb is in your PATH so you can call it from anywhere. The .red configuration file should be in the same folder as wherever you run red.rb from. In my case, I create one in the root of each project.
Let me know if this helps or ping me again for any more info.
Cheers,
Dave
RE: Control Redmine from the command line - Added by Christian Ribe about 15 years ago
Thanks Dave!
That helped me get started but there seems to be missing some steps.
I also had to perform these steps.
1st
cd to my ruby folder
cd /opt/redmine-0.8.6-0/ruby/bin
2nd
Install trollop and mechanize gems (since they are not present on my system)
sudo ./gem install trollop sudo ./gem install mechanize
Now only step missing is the configuration file which I don't know what file name it expects?
==An example configuration file== username: dave password: d4ve url: http://www.myredmineinstance.com project: redcmd tracker: bug priorty: normal
I named it red.red but that's not it. I get this:
/opt/redmine-0.8.6-0/ruby/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize/chain/uri_resolver.rb:53:in `handle': need absolute URL (RuntimeError) from /opt/redmine-0.8.6-0/ruby/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize/chain.rb:25:in `handle' from /opt/redmine-0.8.6-0/ruby/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize.rb:457:in `fetch_page' from /opt/redmine-0.8.6-0/ruby/lib/ruby/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize.rb:238:in `get' from ../../apps/redmine/red.rb:70:in `login' from ../../apps/redmine/red.rb:63:in `initialize' from ../../apps/redmine/red.rb:174:in `new' from ../../apps/redmine/red.rb:174
Any ideas?
Thanks
RE: Control Redmine from the command line - Added by Dave Nolan almost 15 years ago
By default it expects config file to be called .red
but you can override this per-command by passing in -filename YOUR_FILENAME_GOES_HERE
option.
Dave
RE: Control Redmine from the command line - Added by Alberto Fanjul Alonso over 8 years ago
You can use
https://albfan.github.io/RedmineJavaCLI
It is a resurrect project with a good codebase, and with active developing.
I'm using it on daily basis:
- list my issues
- see issue details: journals, time entries
- change issue status
- add issue comments, private too.
- list time-entries, with subtotal by day or week or whatever
- add time entries
- alias feature avaliable
- ~/.redmine config file
- bash autocompletion
Its only big mistake is to choose java as technology, as it works bad as a cli.
https://github.com/albfan/RedmineJavaCLI/issues/2
Solving this could be a great project, and another app that returns to terminal, as it should be.