Project

General

Profile

Web service when creating or updating an issue

Added by Alice Etchegaray over 9 years ago

Hi all,

I would like to bind Redmine to Icescrum with a REST API : when creating or updating an issue in Redmine, that will automatically do the same for a story in Icescrum.
But, I have never done a web service, and even with the docs of Redmine and Icescrum, I don't see how to do that.

Is anyone among you who can explain me the process, step by step, please ?

I hope you will help me,

Cheers,

Alice.


Replies (5)

RE: Web service when creating or updating an issue - Added by Martin Denizet (redmine.org team member) over 9 years ago

Hi Alice,

You would have to make a plugin that adds a after_save callback on the Issue model.
In this callback you should consume the Icescrum REST API.
To consume the Icescrum REST API you could use one of the following:

Cheers,

RE: Web service when creating or updating an issue - Added by Alice Etchegaray over 9 years ago

Hi Martin, thank you for you help.

I have a question : what language should I use to write this web service ?
And where to place the script ?
I don't absolutely see how to do that...

I would like to have something like :


<application xmlns:xsi="https://icescrum.fr/"
<story>
<acceptanceTests />
<acceptedDate />
<actor />
<affectVersion />
<creationDate><%= issue.created_date ></creationDate>
<creator id="60" />
<dependsOn />
<description><
= issue.subject ></description>
<doneDate />
<effort/>
<estimatedDate><
= issue.due_date ></estimatedDate>
<executionFrequency>1</executionFrequency>
<feature><
= issue.project_id ></feature>
<inProgressDate />
<lastUpdated />
<name><
= issue.subject ></name>
<notes><
= issue.description ></notes>
<parentSprint />
<plannedDate />
<rank />
<state><
if(@issue.custom_field_value(2) = "AgileForce") > 1 < else > 3 < end %></state>
<suggestedDate />
<tasks />
<type>0</type>
<uid>1031</uid>
<tags />
<dependences />
<testState>0</testState>
<comments />
</story>

Can you understand me ?
Do you have an example to explain me correctly ?

Thank you very much,

Cheers,
Alice.

RE: Web service when creating or updating an issue - Added by Martin Denizet (redmine.org team member) over 9 years ago

Hey Alice,
I don't have time to do the work for you but here are the steps if I'd do it:
  1. Create a new plugin http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial
  2. Create a patch for the Issue model
    redmine_my_plugin/lib/patches/issue_patch.rb
    # require your Rest lib here
    module RedmineMyPlugin
      module Patches
        module IssuePatch
          unloadable
    
          def self.included(base)
            base.send(:include, InstanceMethods)
    
            base.class_eval do
              unloadable # Send unloadable so it will not be unloaded in development
    
              after_save :save_in_icesrum
              after_destroy :delete_in_icescrum
            end
          end
    
          module InstanceMethods
            def save_in_icesrum
              if self.persisted?
                # Call RestAPI here.
                # Issue's id is self.id
              end
            end
            def delete_in_icescrum
              # Call RestAPI here.
            end
          end
        end
      end
    end
    

I didn't test this code. (No time, sorry!)

You will find sensibly the same code in Eric Davis' Kanban plugin.

For the API call itself, read the documentation of the library you chose.
Note that you should create a Gemfile file at the root of your plugin. It should contain the reference of the Rest library you want to use. And also you will need to run a bundle install for it to be available.

RE: Web service when creating or updating an issue - Added by Alice Etchegaray over 9 years ago

Ok, thank you very much...
I will try this and keep yourself informed :)

    (1-5/5)