Skip to content
Browse files

Fix bugs in jira ticket posting

  • Loading branch information...
1 parent cd6bea8 commit fa4828e3d6ddf930608e7efe575debafc8816610 @beberlei committed Feb 29, 2012
Showing with 11 additions and 8 deletions.
  1. +1 −1 Makefile
  2. +8 −5 app/app.php
  3. +1 −1 example.json
  4. +1 −1 packaging_config.php
View
2 Makefile
@@ -2,7 +2,7 @@
# modify it manually. If you want to modify the Makefile model, modify the
# packaging/Makefile.in file
NAME=beberlei-github2jira
-VERSION=1.0
+VERSION=1.0.1
MAINTAINER=Benjamin Eberlei <kontakt@beberlei.de>
PACKAGENAME=beberlei-github2jira
PACKAGETYPE=deb
View
13 app/app.php
@@ -6,7 +6,7 @@
$app = new Application();
$app->post('/jira/{username}/{project}/accept-pull', function($username, $project, Application $app, Request $request) {
$project = loadProject($username, $project);
- synchronizePullRequest($request->get('payload'), $project);
+ synchronizePullRequest(json_decode($request->get('payload')), $project);
return new Response('{"ok":true}', 201, array('Content-Type' => 'application/json'));
});
@@ -22,14 +22,17 @@ class JiraProject
public $uri;
public $username;
public $password;
- public $projectShortname;
+ public $shortname;
public $ticketType;
public $assignUsername;
public $template;
}
function synchronizePullRequest($pullRequest, JiraProject $project)
{
+ if (!isset($pullRequest->html_url)) {
+ throw new \RuntimeException("Missing html url in Pull Request");
+ }
$client = new \Zend\XmlRpc\Client($project->uri);
$token = $client->call("jira1.login", array($project->username, $project->password));
@@ -54,7 +57,7 @@ function synchronizePullRequest($pullRequest, JiraProject $project)
$data = $client->call("jira1.createIssue", array($token, array(
"summary" => $issuePrefix . " by " . $pullRequest->user->login . ": " . $pullRequest->title,
- "project" => $jiraProjectShortname,
+ "project" => $project->shortname,
"description" => $body,
"type" => $project->ticketType,
"assignee" => $project->assignUsername
@@ -70,8 +73,8 @@ function loadProject($username, $project)
throw new \RuntimeException("Invalid project name given!");
}
- $config = json_decode(file_get_contents(__DIR__. "/../config/". $username."-".$project.".json"));
- $requiredValues = array("uri", "username", "password", "ticketType", "projectShortname", "hash");;
+ $config = json_decode(file_get_contents(__DIR__. "/../config/". $username."-".$project.".json"), true);
+ $requiredValues = array("uri", "username", "password", "ticketType", "shortname", "hash", "assignUsername");;
$project = new JiraProject();
$project->ticketType = 4;
$project->template = <<<ISSUETEXT
View
2 example.json
@@ -3,5 +3,5 @@
"username": "",
"password": "",
"ticketType": 4,
- "projectShortname": "DDC"
+ "shortname": "DDC"
}
View
2 packaging_config.php
@@ -1,6 +1,6 @@
$configure = array(
'packagename' => 'beberlei-github2jira',
- 'version' => '1.0',
+ 'version' => '1.0.1',
'maintainer' => 'Benjamin Eberlei <kontakt@beberlei.de>',
'description' => 'Turns Github PRs into Jira Tickets',
'url' => 'http://www.beberlei.de',

0 comments on commit fa4828e

Please sign in to comment.
Something went wrong with that request. Please try again.