Husterknupp / jubilant-todo-tribble

find repo todos, create Jira tickets and reference todos in the tickets.
Apache License 2.0
2 stars 0 forks source link

Connect to Jira #7

Closed Husterknupp closed 7 years ago

Husterknupp commented 7 years ago

Programmatically create an issue

Bantolomeus commented 7 years ago

Jira version: JIRA v7.2.6

Bantolomeus commented 7 years ago

to get all issues assigned to a specific user: curl -D- -u username:password -X GET -H "Content-Type: application/json" https://nameOfYourJira/rest/api/2/search?jql=assignee=username

as define in the curl command, the response is a json object

Now, that the connection works, the next step is to create a new issue via rest api.

Bantolomeus commented 7 years ago

To authenticate you simply add a parameter in the url, like in the curl command above.

Bantolomeus commented 7 years ago

@Husterknupp Do you mean we should log the new creation of a issue with a logger (I think so, but I want to be 100% sure)? Please be patient with me =)

Husterknupp commented 7 years ago

@Bantolomeus yes, you're absolutely right. The idea was to add transparency on what our app is doing. Everytime it finds a new todo and adds a Jira issue for that todo, an interested person should be able to find information about it. Either in logs or as a REST endpoint or whatever. I found the logging option the easiest for now.

Bantolomeus commented 7 years ago

a example curl command to create a issue (documented here) curl -u admin:admin -X POST --data @data.txt -H "Content-Type: application/json" https://jiraAdress/rest/api/2/issue/

data.txt: { "fields": { "project": { "id": "10000" }, "summary": "No REST for the Wicked.", "description": "Creating of an issue using ids for projects and issue types using the REST API", "issuetype": { "id": "3" } } }

The shown curl command differs from the documentation. It works as shown here.

Bantolomeus commented 7 years ago

To get the meta datas of our jira you can use this curl command: curl -D- -u username:password -X GET -H "Content-Type: application/json" https://jira.whatEver/api/2/issue/createmeta

Bantolomeus commented 7 years ago

for assignee you can use the name shortage from gitlab (between two and four letters)

Bantolomeus commented 7 years ago

for now create a standard component and always use this standard component.

Bantolomeus commented 7 years ago

see #10 for later component setting handling

Bantolomeus commented 7 years ago

summary in data.txt is the issue title

Bantolomeus commented 7 years ago

here is a link of possible settings: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-add-component-while-creating-an-issue-via-JIRA-REST-API/qaq-p/493660

Bantolomeus commented 7 years ago

curl command to create a new issue: curl -u username:password -X POST --data @data.txt -H "Content-Type: application/json" https://jiraAdress/rest/api/2/issue/

data.txt: { "fields": { "project": { "id": "projectId" }, "summary": "title", "description": "description", "issuetype": { "id": "issueTypeId" }, "assignee": { "name": "username" }, "components": [ { "id": "componentId" } ] } }

Husterknupp commented 7 years ago

for how to add json object to your http request, look here: http://khttp.readthedocs.io/en/latest/user/quickstart.html#more-complicated-post-requests

Husterknupp commented 7 years ago

we need 1. Authorization and 2. content-type header

val authHeader = String(Base64.getEncoder().encode("USERNAME:PW".toByteArray()));
        // addHeader("Authorization", "Basic " + auth);
        // setHeader("content-type", "application/json");
Bantolomeus commented 7 years ago

for further usage the createJiraIssue method needs configurable summary and description

Husterknupp commented 7 years ago

@Bantolomeus Code is not compiling. see my code comment.

Husterknupp commented 7 years ago

https://github.com/Husterknupp/jubilant-todo-tribble/commit/afee3fb12fb8178332f3559ea05b58b5fdde10fc#commitcomment-21935226

Bantolomeus commented 7 years ago

I get this error: (default) on project jubilant-todo-tribble: The plugin pl.project13.maven:git-commit-id-plugin:2.2.1 requires Maven version [3.1.1,) -> [Help 1]

@Husterknupp Did you added this? Can you solve this? I have a lot more dependency errors

Husterknupp commented 7 years ago

I didn't add the git-commit-id plugin lately. It's in the repo since the beginning.

Did you checkout the latest commit and tried mvn clean compile -U ?

Am 27.04.2017 um 18:38 schrieb Christian Bantel notifications@github.com<mailto:notifications@github.com>:

I get this error: (default) on project jubilant-todo-tribble: The plugin pl.project13.maven:git-commit-id-plugin:2.2.1 requires Maven version [3.1.1,) -> [Help 1]

@Husterknupphttps://github.com/Husterknupp Did you added this? Can you solve this? I have a lot more dependency errors

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Husterknupp/jubilant-todo-tribble/issues/7#issuecomment-297770589, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABNO5ir-u2u5q8_wgcnSPCqhPk26edbwks5r0MR2gaJpZM4ND6UF.

Bantolomeus commented 7 years ago

I still have the dependency problems. Thats why I can not run mvn test. I pushed the credentials class with all needed methods. @Husterknupp please test if the application runs if you pull and fill out the Return values in Credentials.kt with the correct values

Bantolomeus commented 7 years ago

I had to delete and recreate the Credentials class to be able to commit it.

Husterknupp commented 7 years ago

@Bantolomeus sorry for this gitignore hassle. Thank you for the now compiling code. Let me double check if I have dependency problems.

In the meanwhile maybe this can be useful for you https://deutsch.lingolia.com/en/vocabulary/easily-confused-words/das-vs-dass

Husterknupp commented 7 years ago

mvn -U clean package outputs BUILD SUCCESS for me. What are your dependency problems?

Husterknupp commented 7 years ago

Implementation wise, can you please rework the issue title and the issue description to be method params? Makes sense to actually put information about a todo into the issue, right?

Bantolomeus commented 7 years ago

Done and of course it makes sense.

Husterknupp commented 7 years ago

method params found