Frage

I'm trying to use the jira-ruby Gem to interface with a remote JIRA server with 5.x REST API.

Accessing data on the server works well, but it seems I can not create a new JIRA issue remotely. The Gem's documentation is minimal, and there are no examples provided.

Can somebody provide a working example on:

  • how to create a remote JIRA Issue with ruby-jira
  • how to attach a file to an existing Issue
War es hilfreich?

Lösung

To create new JIRA Issue use:

CODE:

issue = client.Issue.build
issue.save({"fields"=>{"summary"=>"blarg from in example.rb","project"=>{"id"=>"10001"},"issuetype"=>{"id"=>"3"}}})
issue.fetch
pp issue

Or

You can try REST APIs to create JIRA Issue.

Using IDs

The first example creates an issue by specifying the project ID and issue type ID. Request

curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/

Data

Here's the JSON:

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

Response

The response provides the issue ID, issue key, and the URL to the issue (which can then be used to GET additional data, PUT updates, etc).

{
   "id":"39001",
   "key":"TEST-102",
    "self":"http://localhost:8090/rest/api/2/issue/TEST-102"
}

Using Project Key and Field Names

Alternatively, you can create an issue by specifying the project key and field names. Request

curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/

Data

{
    "fields": {
       "project":
       {
          "key": "TEST"
       },
       "summary": "REST ye merry gentlemen.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Bug"
       }
   }
}

Response

{
   "id":"39000",
   "key":"TEST-101",
    "self":"http://localhost:8090/rest/api/2/issue/TEST-101"
}

Source: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top