Last active
March 20, 2018 15:16
-
-
Save takezoe/0ed9ab3093d3b9ca2869 to your computer and use it in GitHub Desktop.
GitBucket Plug-in Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var plugin = JavaScriptPlugin.define( | |
'export-issues', '1.0.0', | |
'Naoki Takezoe', | |
'https://twitter.com/takezoen', | |
'Export issues as JSON from REPO_URL/issues/export.' | |
); | |
plugin.addRepositoryAction('/issues/export', function(request, response, repository){ | |
var issues = plugin.db().select("SELECT * FROM ISSUE WHERE "+ | |
"USER_NAME ='" + repository.owner() + "' AND " + | |
"REPOSITORY_NAME ='" + repository.name() + "' AND " + | |
"PULL_REQUEST = false"); | |
var result = []; | |
for(var i = 0; i < issues.length; i++){ | |
result[i] = { | |
issueId : '' + issues[i].get('ISSUE_ID'), | |
title : '' + issues[i].get('TITLE'), | |
content : '' + issues[i].get('CONTENT'), | |
openedUserName : '' + issues[i].get('OPENED_USER_NAME'), | |
assignedUserName : '' + issues[i].get('ASSIGNED_USER_NAME'), | |
closed : '' + issues[i].get('CLOSED'), | |
registeredDate : '' + issues[i].get('REGISTERED_DATE'), | |
updatedDate : '' + issues[i].get('UPDATED_DATE') | |
}; | |
} | |
return { | |
format: 'json', | |
body: JSON.stringify(result) | |
}; | |
}); | |
PluginSystem.install(plugin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment