Project

General

Profile

Adding new version to project using Ruby API

Added by Marcin Garski almost 8 years ago

Hey,
How can I add new version object to Redmine project using Ruby API? I'd like to automate some processes in Ruby script.
I've add new class

require_relative 'redmine_connection'
class RedmineVersion < RedmineConnection
  self.element_name = 'version'
end

RedmineConnection.rb stores credentials and inherits from ActiveResource::Base - that works good, I can connect to Redmine API and read, e.g., Issues.

class RedmineConnection < ActiveResource::Base
  self.site = 'http://redmine-test/'
  self.user = 'tmpuser'
  self.password = 'secret'
  self.format = :xml
end

Wiki says that Version needs only project_id and name, these are required.

This doesn't work:

version = RedmineVersion.new(
  :project_id => 12,
  :name => "Another version",
)

I've also tried to connect to Redmine from rails script/console option and create new Version - no problem with that, I've only passed project_id and name, save after that and new Version was added.

Can someone give me an example how to add Version object to Redmine project?

Thanks for help.
Gary