HowTo Mylyn » History » Version 54

Morty Morty, 2018-06-08 12:01
Add example query

1 1 Jean-Philippe Lang
h1. HowTo connect a Mylyn repository to Redmine
2 1 Jean-Philippe Lang
3 13 Mischa The Evil
{{>TOC}}
4 1 Jean-Philippe Lang
5 27 Felix Schäfer
These instructions should work with redmine 0.9 stable and up.
6 27 Felix Schäfer
7 29 Felix Schäfer
There are 2 options to connect Mylyn to redmine: either install the connector in your redmine install (this obviously needs the ability to install a plugin on the redmine you want to use it with), or use the generic web connector, which scraps the html pages for the information it needs, and thus should work with pretty much every up-to-date enough redmine installation out there.
8 29 Felix Schäfer
9 29 Felix Schäfer
h2. Using specialized Redmine-Mylyn connector
10 29 Felix Schäfer
11 44 Hans Kaiser
The Redmine Mylyn Connector is under "volatile" development. So you will find multiple pages and forks, here are some jump points.
12 44 Hans Kaiser
http://www.redmine.org/boards/1/topics/10923
13 48 Frederic Sop
http://sourceforge.net/projects/redmin-mylyncon/ - Eclipse 4.x : https://github.com/ljader/redmine-mylyn-plugin
14 49 Hedayat Vatankhah
http://danmunn.github.io/redmine_mylyn_connector/ (Currently, https://github.com/joaopedrotaveira/redmine_mylyn_connector has better Redmine 3.x.x compatibility)
15 44 Hans Kaiser
16 44 Hans Kaiser
h3. The sourceforge way
17 45 Michael Nagel
18 48 Frederic Sop
The "Redmine-Mylyn Connector":http://sourceforge.net/projects/redmin-mylyncon/ is another solution providing better integration with Mylyn (Note: for version 2 of Redmine, the updated redmine plugin can be found "here":http://danmunn.github.com/redmine_mylyn_connector and also an updated Redmine connector plugin for Eclipse (Mylyn) which solves some problems with newer versions (Eclipse 4.x) is "here":https://github.com/ljader/redmine-mylyn-plugin).
19 29 Felix Schäfer
20 30 Felix Schäfer
p=. !redmin-mylyncon.png!
21 30 Felix Schäfer
22 13 Mischa The Evil
h2. Using the generic web repository connector
23 13 Mischa The Evil
24 1 Jean-Philippe Lang
"Mylyn":http://www.eclipse.org/mylyn is an Eclipse plugin for task management.
25 1 Jean-Philippe Lang
This HowTo explains how to connect to Redmine using the generic web repository connector.
26 1 Jean-Philippe Lang
27 6 Mischa The Evil
Note that the generic web repository connector is not part of the default Mylyn install.
28 39 Etienne Massip
So, you have to install it first from the "_incubator_ update site":http://download.eclipse.org/mylyn/incubator/3.8.
29 1 Jean-Philippe Lang
30 13 Mischa The Evil
h3. Create a Task Repository
31 1 Jean-Philippe Lang
32 1 Jean-Philippe Lang
# Right-click on the task repositories list and click *Add task repository*
33 5 Jeffrey Price
# Choose _Web Template (Advanced)_ and click *Next*
34 1 Jean-Philippe Lang
# Configure the repository:
35 2 Jean-Philippe Lang
36 1 Jean-Philippe Lang
<pre>
37 1 Jean-Philippe Lang
Server:                 http://www.redmine.org -- Replace it with the URL of your Redmine instance
38 27 Felix Schäfer
Task URL:               ${serverUrl}/issues/
39 1 Jean-Philippe Lang
New task URL:           ${serverUrl}/projects/foo/issues/new -- Replace foo with the identifier of the project used for new tasks
40 1 Jean-Philippe Lang
Query request URL:      ${serverUrl}/issues
41 27 Felix Schäfer
Query pattern:          <td class="subject">.*?<a href="/issues/(\d+)">(.+?)</a></td>
42 27 Felix Schäfer
Login request URL:      ${serverUrl}/login?username=${userId}&password=${password}&authenticity_token=${loginToken} [POST]
43 27 Felix Schäfer
Login Form URL:         ${serverUrl}/login
44 46 Felix Schäfer
Login Token Pattern:    <input name="authenticity_token" type="hidden" value="(.+?)">
45 1 Jean-Philippe Lang
</pre>
46 1 Jean-Philippe Lang
47 47 None None
If you have problems with login, maybe try this (mind the end
48 47 None None
<pre>
49 47 None None
Login Token Pattern:    <input name="authenticity_token" type="hidden" value="(.+?)" />
50 47 None None
</pre>
51 47 None None
52 29 Felix Schäfer
Example:
53 2 Jean-Philippe Lang
54 28 Felix Schäfer
p=. !mylyn-repository-properties-2.png!
55 26 Felix Schäfer
56 1 Jean-Philippe Lang
You can replace the _Query request URL_ parameter with the following if you want to get only the issues that are assigned to you:
57 2 Jean-Philippe Lang
58 2 Jean-Philippe Lang
  ${serverUrl}/issues?set_filter=1&assigned_to_id=me
59 2 Jean-Philippe Lang
60 15 Alistair MacDonald
The following Query pattern value reads Status, Owner and Tracker fields too (Mylyn 3.2.1) :
61 10 Etienne Massip
<pre>
62 32 Felix Schäfer
<td class="tracker">({Type}.+?)</td><td class="status">({Status}.+?)</td>.+?<td class="subject">.*?<a href=".*?/issues/({Id}\d+)">({Description}.+?)</a></td>({Optional}<td class="assigned_to"><a href.+?>({Owner}.+?)</a></td>)?</pre>
63 10 Etienne Massip
64 1 Jean-Philippe Lang
Status is read as "uncomplete" or "complete" in Eclipse.
65 2 Jean-Philippe Lang
66 7 steeven lee
h3. Create a Query
67 1 Jean-Philippe Lang
68 7 steeven lee
* On the task list, right-click and choose *New* -> *Query...*
69 13 Mischa The Evil
* And select your newly created repository
70 7 steeven lee
71 13 Mischa The Evil
p=. !mylyn-task-list.png!
72 50 Bastian Lüttig
73 51 Bastian Lüttig
h2. Web Templates on Redmine 3.3+
74 50 Bastian Lüttig
75 50 Bastian Lüttig
The following information applies to Redmine versions 3.3+ and Eclipse Neon (4.6) and will make use of the REST Interface and API Key.
76 50 Bastian Lüttig
77 50 Bastian Lüttig
h3. Prerequisites
78 50 Bastian Lüttig
79 50 Bastian Lüttig
Installed Redmine 3.3+, Eclipse 4.6+
80 50 Bastian Lüttig
81 50 Bastian Lüttig
Add MyLyn Incubator: http://download.eclipse.org/mylyn/incubator/latest/
82 50 Bastian Lüttig
Install _Mylyn Tasks Connector: Web Templates (Advanced) (Incubation)_
83 50 Bastian Lüttig
84 50 Bastian Lüttig
h3. Add new MyLyn Repository
85 50 Bastian Lüttig
86 50 Bastian Lüttig
Server: your server URL
87 50 Bastian Lüttig
Label: Your Label
88 50 Bastian Lüttig
check "Anonymous" box
89 50 Bastian Lüttig
90 50 Bastian Lüttig
Click _Additional Settings_, add 3 Parameters:
91 50 Bastian Lüttig
key -> your API key
92 50 Bastian Lüttig
projectId -> your project name
93 50 Bastian Lüttig
limit -> 100
94 50 Bastian Lüttig
95 50 Bastian Lüttig
Click _Advanced Configuration_ 
96 50 Bastian Lüttig
<pre>
97 50 Bastian Lüttig
Task URL: ${serverUrl}/issues/
98 50 Bastian Lüttig
New Task URL: ${serverUrl}/projects/${projectId}/issues/new
99 50 Bastian Lüttig
Query Request URL: ${serverUrl}/issues.xml?key=${key}&project_id=${projectId}&limit=${limit}
100 52 Bastian Lüttig
Query Pattern: <issue><id>({Id}\d+)<\/id>.*?<tracker id="\d+" name="({Type}.*?)"\/><status id="\d+" name="({Status}.*?)"\/>.*?<assigned_to id="\d+" name="({Owner}.*?)"\/>.*?<subject>({Description}.*?)<\/subject>
101 50 Bastian Lüttig
</pre>
102 50 Bastian Lüttig
103 53 Morty Morty
Alternative Query Pattern that also works when a ticket is not assigned to someone (not very well tested yet):
104 53 Morty Morty
<pre>
105 53 Morty Morty
<issue><id>({Id}\d+)<\/id>.*?<tracker id="\d+" name="({Type}.*?)"\/><status id="\d+" name="({Status}.*?)"\/>.*?(?:<assigned_to id="\d+" name="({Owner}.*?)"\/>.*?)?<subject>({Description}.*?)<\/subject>
106 53 Morty Morty
</pre>
107 53 Morty Morty
108 53 Morty Morty
109 50 Bastian Lüttig
Leave the rest as is.
110 50 Bastian Lüttig
111 50 Bastian Lüttig
h3. Create new Query
112 50 Bastian Lüttig
113 54 Morty Morty
Adapt Parameters, if necessary. You can add your own parameters to taylor the list further. For example tp only query your own tasks use:
114 54 Morty Morty
<pre>
115 54 Morty Morty
${serverUrl}/issues.xml?key=${key}&project_id=${projectId}&limit=${limit}&assigned_to_id=me
116 54 Morty Morty
</pre>
117 50 Bastian Lüttig
More information can be found inside the "REST Documentation":http://www.redmine.org/projects/redmine/wiki/Rest_Issues
118 50 Bastian Lüttig
119 50 Bastian Lüttig
h3. General notes
120 50 Bastian Lüttig
121 50 Bastian Lüttig
If you want to use the connection as mentioned above via HTTP, you need to adapt the Login Token Pattern.
122 50 Bastian Lüttig
123 50 Bastian Lüttig
It is with current Redmine versions as follow:
124 50 Bastian Lüttig
<pre>
125 50 Bastian Lüttig
<input type="hidden" name="authenticity_token" value="(.+?)" />
126 50 Bastian Lüttig
</pre>