Regarding Redmine, which is a project management SW, the operation to read information using Python is summarized. It was carried out in the following environment.
os | windows |
python | 3.7.1 |
python-redmine | 2.3.0 |
anaconda | 4.8.5 |
API that can operate Redmine from Python. Tickets and projects can be created, loaded, updated and deleted. This article is for reading only.
Install from anaconda cloud.
$ conda install -c auto python-redmine
To connect to Redmine, you need to set it on Remine side and python side.
A user with administrator privileges configures Redmine. Enable [Administration] → [Settings] → [Enable Web Services by REST API].
Use the information of the accessing user (user name and password) or API access key.
from redminelib import Redmine
REDMINE_URL = r'http://user/redmine' #Redmine path
REDMINE_KEY = 'xxxxxx' #API access key
redmine = Redmine(REDMINE_URL, key = REDMINE_KEY)
Or
from redminelib import Redmine
REDMINE_URL = r'http://user/redmine' #Redmine path
USER = 'hoge' #User name
PASS = 'hogehoge' #password
redmine = Redmine(REDMINE_URL, username = USER, password = PASS)
There are three ways to get Redmine ticket information: get (), all (), and filter (). If you want to get only a specific ticket, get it with redmine.issue.get (ticket ID). The information in the acquired ticket is in the object that is the return value. If the ticket with the target ticket ID does not exist, a redmine.exceptions.ResourceNotFoundError exception will be thrown.
from redminelib import Redmine
from redminelib.exceptions import ResourceNotFoundError
REDMINE_URL = r'http://user/redmine' #Redmine path
REDMINE_KEY = 'xxxxxx' #API access key
redmine = Redmine(REDMINE_URL, key = REDMINE_KEY)
ticket_id = 4
try:
issue = redmine.issue.get(ticket_id)
except(ResourceNotFoundError):
print('Ticket ID %s not found' % ticket_id)
Summarize the contents described in detail in python-redmine. https://python-redmine.com/resources/issue.html If the corresponding information is not registered in the ticket, the ISSUE property itself does not exist. Therefore, it is necessary to determine whether or not the property is possessed for information acquisition.
info = issue.property if hasattr(issue, 'property') else None
Redmine information | Information in ISSUE |
---|---|
Ticket ID | issue.id |
Ticket URL | issue.url |
Tracker ID | issue.tracker.id |
Tracker | issue.tracker.name |
Title | issue.subject |
Explanation | issue.description |
Status ID | issue.status.id |
status | issue.status.name |
Priority ID | issue.priority.id |
priority | issue.priority.name |
Person in charge ID | issue.assigned_to.id |
Person in charge name | issue.assigned_to.name |
Parent ticket ID | issue.parent |
start date | issue.start_date |
Deadline | issue.due_date |
Estimated time | issue.estimated_hours |
Project ID | issue.project.id |
project | issue.project.name |
Creator ID | issue.author.id |
Creator name | issue.author.name |
Progress rate | issue.done_ratio |
Created date | issue.created_on |
Update date | issue.updated_on |
Working hours | issue.spent_hours |
If there is a plurality of information, each information is included in each object.
Watcher | issue.watchers | |
Watcher ID | .id | |
Watcher name | .name | |
Custom area | issue.custom_fields | |
Custom ID | .id | |
Custom name | .name | |
Custom value | .value | |
Send file | issue.attachments | |
File ID | .id | |
file name | .filename | |
File description | .description | |
file size | .filesize | |
File author | .author | |
File URL | .content_url | |
File creation date | .created_on | |
Commit log | issue.changesets | |
Child ticket | issue.children | |
Child ticket ID | .id | |
Child ticket title | .subject | |
Related tickets | issue.relations | |
Related ID | .id | |
Related own ID | .issue_id | |
Related partner's ID | .issue_to_id | |
Related type | .relation_type |
https://qiita.com/mima_ita/items/1a939db423d8ee295c85 https://python-redmine.com/resources/issue.html
Recommended Posts