Create Projects from the command line?

Added by Karsten Heymann over 5 years ago

Hi,

is there a way to create projects from the command line? We're using redmine as an very advanced repository browser. Currently I'm creating a lot of small git repositories for separate software packages, and there's quite some manual work to be done to activate them.

Any hints appreciated,
Karsten

Replies (3)

RE: Create Projects from the command line? - Added by Jason Messmer over 5 years ago

I believe you can use (wget,curl) to post. I never done it but I thought redmine is RESTFUL?

RE: Create Projects from the command line? - Added by Eric Davis over 5 years ago

Karsten Heymann wrote:

is there a way to create projects from the command line? We're using redmine as an very advanced repository browser. Currently I'm creating a lot of small git repositories for separate software packages, and there's quite some manual work to be done to activate them.

You can use the Rails console and runner to run commands from the command line. I'd recommend starting with the console first because it's interactive and you can work out the bugs there. Then you can write a script and send it to the runner to "run". I'm working on a plugin that will generate a bunch of random data for Redmine, including projects. You can use that as a starting point for your script. Here's a snippet you can paste into the console. The second command will print out any error messages, like missing data.

# From: http://github.com/edavis10/redmine_data_generator/blob/37b8acb63a4302281641090949fb0cb87e8b1039/app/models/data_generator.rb#L36
project = Project.create(
                         :name => "This is my project name",
                         :description => "It has a description",
                         :identifier => "unique-id" 
                         )

puts project.errors.full_messages

Here's how to active the console and runner

  • Rails console - ruby script/console production
  • Rails runner - ruby script/runner -e production 'puts "some code"'

Jason Messmer wrote:

I believe you can use (wget,curl) to post. I never done it but I thought redmine is RESTFUL?

Redmine doesn't have a REST API yet (blame me).

Eric

RE: Create Projects from the command line? - Added by Karsten Heymann over 5 years ago

Hello Eric,

thank you for your detailed suggestions. So it seems my time has finally come to learn some Ruby ;-) A soon I got something working, I'll post it here for others to benefit from it.

Karsten

(1-3/3)