Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_wcms_tools
Commits
c40145d2
Commit
c40145d2
authored
Jun 07, 2021
by
Liam Morland
Browse files
RT#988316/ISTWCMS-3213: Improve error handling when Jira API is not accessible
parent
69d18ab1
Changes
3
Hide whitespace changes
Inline
Side-by-side
uw_wcms_tools.drupal.modules.inc
View file @
c40145d2
...
...
@@ -105,6 +105,10 @@ function uw_wcms_tools_create_module_update_tickets($module, $version, $depended
require_once
'uw_wcms_tools.jira.inc'
;
uw_wcms_tools_create_jira_for_rt
(
$id
,
$links
);
if
(
!
isset
(
$jira_ticket
->
key
))
{
drupal_set_message
(
t
(
'Failed to create corresponding Jira ticket.'
),
'error'
);
}
}
else
{
throw
new
Exception
(
'Failed to create RT ticket.'
);
...
...
uw_wcms_tools.jira.inc
View file @
c40145d2
...
...
@@ -49,7 +49,7 @@ function uw_wcms_tools_jira_api_query($path, stdClass $data = NULL, $method = 'P
}
$url
=
'https://'
.
$jira_username
.
':'
.
$jira_password
.
'@jira.uwaterloo.ca/rest/api/2/'
.
$path
;
$results
=
@
file_get_contents
(
$url
,
FALSE
,
$context
);
$results
=
file_get_contents
(
$url
,
FALSE
,
$context
);
if
(
$results
)
{
return
json_decode
(
$results
);
}
...
...
@@ -63,8 +63,11 @@ function uw_wcms_tools_jira_api_query($path, stdClass $data = NULL, $method = 'P
* documentation.
*/
function
uw_wcms_tools_jira_api_ticket_create
(
stdClass
$jira_ticket
)
{
foreach
(
uw_wcms_tools_jira_api_query
(
'issue'
,
$jira_ticket
)
as
$key
=>
$value
)
{
$jira_ticket
->
$key
=
$value
;
$result
=
uw_wcms_tools_jira_api_query
(
'issue'
,
$jira_ticket
);
if
(
is_array
(
$result
))
{
foreach
(
$result
as
$key
=>
$value
)
{
$jira_ticket
->
$key
=
$value
;
}
}
}
...
...
@@ -117,7 +120,9 @@ function uw_wcms_tools_create_jira_for_rt($id, array $links = []) {
uw_wcms_tools_jira_api_ticket_create
(
$jira_ticket
);
// Add to the RT ticket a link to the new Jira ticket.
$links
[
'ReferredToBy'
]
=
UW_WCMS_TOOLS_JIRA_URL_PREFIX
.
$jira_ticket
->
key
;
if
(
isset
(
$jira_ticket
->
key
))
{
$links
[
'ReferredToBy'
]
=
UW_WCMS_TOOLS_JIRA_URL_PREFIX
.
$jira_ticket
->
key
;
}
foreach
(
$links
as
$relationship
=>
$target
)
{
$rt
->
addTicketLink
(
$id
,
$relationship
,
$target
);
...
...
uw_wcms_tools.tickets.inc
View file @
c40145d2
...
...
@@ -69,7 +69,7 @@ function uw_wcms_tools_ticket_create_form_submit(array $form, array &$form_state
case
'RT'
:
$jira
=
uw_wcms_tools_create_jira_for_rt
(
$ticket_id
);
$copy_id
=
$jira
->
key
;
$copy_id
=
$jira
->
key
??
NULL
;
break
;
}
...
...
@@ -77,7 +77,12 @@ function uw_wcms_tools_ticket_create_form_submit(array $form, array &$form_state
'!copy'
=>
uw_wcms_tools_get_ticket_link
(
$copy_id
),
'!original'
=>
uw_wcms_tools_get_ticket_link
(
$ticket_id
),
];
drupal_set_message
(
t
(
'Created !copy for !original.'
,
$args
));
if
(
$copy_id
)
{
drupal_set_message
(
t
(
'Created !copy for !original.'
,
$args
));
}
else
{
drupal_set_message
(
t
(
'Failed to create corresponding ticket for !original.'
,
$args
),
'error'
);
}
}
/**
...
...
Liam Morland
@lkmorlan
mentioned in commit
498b7f4b
·
Sep 28, 2021
mentioned in commit
498b7f4b
mentioned in commit 498b7f4b43b25dc5ee0e890f8650b03235c7d1ab
Toggle commit list
Liam Morland
@lkmorlan
mentioned in merge request
!16 (merged)
·
Sep 28, 2021
mentioned in merge request
!16 (merged)
mentioned in merge request !16
Toggle commit list
Liam Morland
@lkmorlan
mentioned in commit
5d6c94c5
·
Feb 18, 2022
mentioned in commit
5d6c94c5
mentioned in commit 5d6c94c5c961563f1d30aeaa7406320f84e54ac6
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment