업무에 빈번하게 활용하고 있는 Jira를 내 취향대로 일목요연하게 정리해보고 싶을 때 다음과 같은 방법으로 웹페이지를 만들어 출력해볼수 있습니다. 핵심적인 부분만 샘플로 추려보면
1. Connection 설정
2. Issues 가져오기
3. HTML로 출력하기
순서입니다.
개인적으로 나중에 알아보기 편하려고 function으로 구분해두었는데, 개발자가 아님을 감안하여 봐주시기를 바라겠습니다.
[ JIRA 연결을 위한 초기 세트 ]
<?php
function initConnection() {
$username = 'JIRA유저아이디';
$password = 'JIRA유저패스워드';
global $curl;
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
}
[ Issues 목록 가져오기 (생성일 순으로 정렬해서 최대 500개) ]
function listIssues() {
echo "<table>";
global $curl, $issues;
curl_setopt($curl, CURLOPT_URL,
"http://JIRA서버:8080/rest/api/2/search?startIndex=0&jql=".
"+order+by+created+asc".
"&maxResults=500");
}
[ 가져온 Issues 출력하기 (Summary,Status,Name,Created,Assignee,Reporter과 Comment 내용) ]
function displayIssues() {
echo "<table border='-1'>";
echo "<tr><th width='120'>Issue Number</th>
<th width='450'>Summary</th>
<th width='100'>Status</th>
<th width='100'>Priority</th>
<th width='200'>Create Date</th>
<th width='80'>Assignee</th>
<th width='80'>Reporter</th>
</tr>";
global $curl, $issues;
$issues = json_decode(curl_exec($curl), true);
foreach ($issues['issues'] as $issue) {
echo "<tr>";
echo "<td bgcolor=#eee>"; echo "<a href='"; print_r("http://JIRA서버:8080/browse/".$issue['key']); echo "'>";
print_r($issue['key']);
echo "</a></td>";
echo "<td bgcolor=#eee><b>"; print_r($issue['fields']['summary']); echo "</b></td>";
echo "<td bgcolor=#ccc><b>"; print_r($issue['fields']['status']['name']); echo "</b></td>";
echo "<td bgcolor=#eee>"; print_r($issue['fields']['priority']['name']); echo "</td>";
echo "<td bgcolor=#eee>"; print_r($issue['fields']['created']); echo "</td>";
echo "<td bgcolor=#eee><b>"; print_r($issue['fields']['assignee']['displayName']); echo "</b></td>";
echo "<td bgcolor=#eee>"; print_r($issue['fields']['reporter']['displayName']); echo "</td>";
echo "<tr><td colspan=7>";
$key = $issue['key'];
curl_setopt($curl, CURLOPT_URL, "http://JIRA서버:8080/rest/api/2/issue/$key/comment");
$comments = json_decode(curl_exec($curl), true);
foreach ($comments['comments'] as $comment) {
echo "<p>» "; print_r($comment['body']); echo "</p>";
}
echo "<font color=#ccc><i>"; print_r($issue['fields']['updated']); echo "</i></font><br>";
echo "</tr>";
}
echo "</table>";
}
[ 그리고 출력하기 ]
initConnection();
listIssues();
displayIssues();
?>
php 파일 하나로 만들어서 호출해보시면 됩니다. 출력 형태를 다양하게 만들어보세요.
댓글 없음:
댓글 쓰기