|
| 1 | + |
| 2 | +# Installation |
| 3 | + |
| 4 | +``` |
| 5 | +composer require lesstif/php-jira-rest-client dev-master |
| 6 | +``` |
| 7 | + |
| 8 | +create config.jira.php file on your project root. |
| 9 | +````php |
| 10 | +<?php |
| 11 | + |
| 12 | +/* |
| 13 | + * Description get Jira Host Configuration |
| 14 | + * |
| 15 | + * @return array |
| 16 | + */ |
| 17 | +function getHostConfig() { |
| 18 | + $jira_config = array ('host' => 'https://jira.example.com', |
| 19 | + 'username' => 'username', |
| 20 | + 'password' => 'secure_passwd'); |
| 21 | + |
| 22 | + return $jira_config; |
| 23 | +} |
| 24 | + |
| 25 | +/** |
| 26 | + * Description get Client options |
| 27 | + * |
| 28 | + * @return array |
| 29 | + */ |
| 30 | +function getOptions() { |
| 31 | + $options = array( |
| 32 | + CURLOPT_SSL_VERIFYHOST => 0, |
| 33 | + CURLOPT_SSL_VERIFYPEER => 0, |
| 34 | + CURLOPT_VERBOSE => false, |
| 35 | + 'LOG_FILE' => 'jira-rest-client.log', |
| 36 | + 'LOG_LEVEL' => \Monolog\Logger::INFO |
| 37 | + ); |
| 38 | + |
| 39 | + return $options; |
| 40 | +} |
| 41 | +?> |
| 42 | +```` |
| 43 | + |
| 44 | +# Usage |
| 45 | + |
| 46 | +## Get Project Info |
| 47 | + |
| 48 | +````php |
| 49 | +try { |
| 50 | + $proj = new ProjectService(); |
| 51 | + |
| 52 | + $p = $proj->get('TEST'); |
| 53 | + |
| 54 | + print_r($p); |
| 55 | +} catch (HTTPException $e) { |
| 56 | + print("Error Occured! " . $e->getMessage()); |
| 57 | +} |
| 58 | +```` |
| 59 | + |
| 60 | +## Get All Project list |
| 61 | +````php |
| 62 | +try { |
| 63 | + $proj = new ProjectService(); |
| 64 | + |
| 65 | + $prjs = $proj->getAllProjects(); |
| 66 | + |
| 67 | + $i = 0; |
| 68 | + foreach ($prjs as $p) { |
| 69 | + echo sprintf("Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n", |
| 70 | + $p->key, $p->id, $p->name, $p->projectCategory['name'] |
| 71 | + ); |
| 72 | + |
| 73 | + } |
| 74 | +} catch (HTTPException $e) { |
| 75 | + print("Error Occured! " . $e->getMessage()); |
| 76 | +} |
| 77 | +```` |
| 78 | + |
| 79 | +## Get Issue Info |
| 80 | + |
| 81 | +````php |
| 82 | +try { |
| 83 | + $issueService = new IssueService(); |
| 84 | + |
| 85 | + $issue = $issueService->get('TEST-867'); |
| 86 | + |
| 87 | + print_r($issue->fields); |
| 88 | +} catch (HTTPException $e) { |
| 89 | + print("Error Occured! " . $e->getMessage()); |
| 90 | +} |
| 91 | +```` |
| 92 | + |
| 93 | +## Create Issue |
| 94 | + |
| 95 | +````php |
| 96 | +try { |
| 97 | + $issueField = new IssueField(); |
| 98 | + $issueField->setProjectId("12000"); |
| 99 | + $issueField->setSummary("something's wrong"); |
| 100 | + $issueField->setAssigneeName("lesstif"); |
| 101 | + $issueField->setPriorityName("Critical"); |
| 102 | + $issueField->setIssueType("Bug"); |
| 103 | + $issueField->setDescription("Full description for issue"); |
| 104 | + |
| 105 | + $issueField->addVersion(null, "1.0.1"); |
| 106 | + $issueField->addVersion(null, "1.0.3"); |
| 107 | + |
| 108 | + $issueService = new IssueService(); |
| 109 | + |
| 110 | + $ret = $issueService->create($issueField); |
| 111 | + |
| 112 | + //If success, Returns a link to the created issue. |
| 113 | + print_r($ret); |
| 114 | +} catch (HTTPException $e) { |
| 115 | + print("Error Occured! " . $e->getMessage()); |
| 116 | +} |
| 117 | +```` |
| 118 | + |
| 119 | +# License |
| 120 | + |
| 121 | +Apache V2 License |
| 122 | + |
| 123 | +# JIRA Rest API Documents |
| 124 | +* 6.2 - https://docs.atlassian.com/jira/REST/6.2/ |
| 125 | +* latest - https://docs.atlassian.com/jira/REST/latest/ |
| 126 | + |
0 commit comments