January 4, 2017

How to create a Custom Plugin in Redmine

Redmine is a free and open source, flexible web based Project management and Issue tracking tool written in Ruby on Rails framework. It is cross-platform and cross-database. We can create our own custom plugin and deploy it in redmine. Here are the steps:

Step 1:
Open Command Prompt For Redmine (Note: Don’t Use normal command prompt of windows.)
To Open command Prompt,
Start -> All Programs->Bitnami Redmine Stake->Use Bitnami Redmine Stake -> Run as Administrator

Then apply below command:
 set RAILS_ENV=production  

This command tells that our Rail environment is Production. To create a plugin, this is initial step . DO NOT forget to execute this command.

Step 2:
To create a custom plugin in Ruby, you have to use command prompt. First, Create a plugin folder. Lets say, suppose I want to create Plugin called "Project Estimation Tracker"

For that I've used below code:
 ruby apps/redmine/htdocs/script/rails g redmine_plugin ProjectEstimationTracker  

Here,
g = Generate
ProjectEstimationTracker = Name of Your plugin.
apps/redmine/htdocs/script/rails = To create a plugin, rails script should be executed.


Step 3:
Now, we have to add our custom page to the plugin . For that, we need to create a controller first.

 ruby apps/redmine/htdocs/script/rails g redmine_plugin_controller ProjectEstimationTracker projecteffortstracking index  

Here,

ProjectEstimationTracker = Name of Your plugin.
projecteffortstracking = Name of Controller
index = action

As a result of above script, it will automatically create default view file in view folder .
In that view file ,we can apply our custom html code.


Step 4:
The most important step for creating a plugin is to configure a route. To configure a route, Go to your plugin folder, then go to Config folder which has routes.config file.
Example: For my plugin routes.config file path is:
"C:\Bitnami\redmine-2.5.1-1\apps\redmine\htdocs\plugins\project_efforts_tracking\config\routes.config"

Edit routes.config file.
 RedmineApp::Application.routes.draw do   
 get 'ProjectEffort', :to => 'projecteffortstracking#index'  
 end  

Here,
get = Name of Plugin (recommended) or any other name which you would like to show in URL.
Example: Here URL will b: http://localhost:90/redmine/ProjectEffort
To => Name of Controller

Step 5:
Final step is to change configuration setting. Go to your plugin folder which have init.rb file.
Example: project_efforts_tracking→ init.rb

Then apply following code:
 Redmine::Plugin.register :project_efforts_tracking do  
  name 'Project Efforts Tracking plugin'  
  author 'Author name'  
  description 'This is a plugin for Redmine'  
  version '0.0.1'  
  url 'http://example.com/path/to/plugin'  
  author_url 'http://example.com/about'  
  menu :admin_menu, :projecteffortstracking, { :controller => 'projecteffortstracking', :action => 'index' }, :caption => 'Project Estimation Tracker'  
 end  

Here, we can mention where we would like to show the plugin, e.g. In Admin menu or Top menu etc.
For different type of menus visit : Redmine Menus
Now, your plugin is ready to use. Restart your server using Bitnami Redmine Stack.
 
If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment