feat: add support for jira server API#33
Conversation
|
Awesome, thanks for the contribution! I will give it a try tomorrow and take a closer look. Much appreciated! |
| end | ||
|
|
||
| local escaped_key = vim.fn.escape(project_key, "&=?") | ||
| local endpoint = string.format("/issue/createmeta?projectKeys=%s&expand=projects.issuetypes", escaped_key) |
There was a problem hiding this comment.
Tried this against a local Jira Data Center (Version: 9.12) and "Create issue" didn't work for me. So far this worked for me for the server case:
if config.jira_config().api_type == "server" then
local endpoint = string.format("/issue/createmeta/%s/issuetypes", escaped_key)
return service.request("GET", endpoint, nil, function(result, err)
if err ~= nil or type(result) ~= "table" then
callback(nil, err or "Empty response")
return
end
local raw_types = result.values
if type(raw_types) ~= "table" then
callback({}, nil)
return
end
local issue_types = {}
for _, raw in ipairs(raw_types) do
local issue_type = normalizer.to_issue_type(raw)
if issue_type ~= nil then
table.insert(issue_types, issue_type)
end
end
callback(issue_types, nil)
end, {
action = "Fetch create metadata",
project_key = project_key,
})
endThere was a problem hiding this comment.
Sorry for overlooking that, and thanks for the fix. I added it in 4d9034d .
On my side, I needed more to make it work, but it's because of the specific Jira server configuration: it seems it didn't enable setting the description of an issue in the REST API (it returns a Field 'description' cannot be set error, similar to this issue). I unfortunately don't have access to the Jira server settings (it's managed by my employer), so I implemented a workaround in 64cec99 , which consists of creating the issue then immediately update it, in case the error is raised: having said that, considering how specific it is, I am happy to remove this commit to keep your codebase clean, just let me know.
There was a problem hiding this comment.
Works like a charm, thank you! The workaround is isolated and will probably save the next person stuck with the same jira config 👍
Just in case you are also using Bitbucket Server -> I have been slowly working on it over the last few weeks and just opened a draft PR for it.
|
@all-contributors please add @xamcost for code |
|
I've put up a pull request to add @xamcost! 🎉 |
Hi there! Thank for this nice plugin. I extended it to support not only the cloud API of Jira, but also the server one. More precisely, this PR introduces two new options in the Jira provider:
api_type: can becloudorserver, defaults tocloudto keep the current behaviour.auth_method: can bebasicorbearer, defaults tobasicto keep the current behaviour.bearerallows you to use an API token only instead of email/password.For reference, I used these docs to implement the server API support.
Of course, feel free to reject this PR if you think it clutters your plugin.