我已经能够使用PHP来生成JIRA问题,但是想知道是否有可能创建链接回JIRA问题的Confluence维基页面。我还没能完成这项工作。有没有人有关于如何实现这一目标的任何例子?
答案 0 :(得分:0)
您可以使用REST API轻松创建新的Confluence页面。以下是使用curl的示例:
curl -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' http://localhost:8080/confluence/rest/api/content/
接下来要做的就是让PHP调用它。请查看以下示例:
完成此操作后,您还可以在Confluence页面中嵌入一个JIRA宏以获得额外的zing。这意味着原始卷曲会将JIRA宏添加为存储格式(在Confluence页面中,单击Tools(或“......”)并选择查看存储格式作为示例。
以下是JIRA宏的示例:
<ac:structured-macro ac:name="jira">
<ac:parameter ac:name="server">Example JIRA</ac:parameter>
<ac:parameter ac:name="serverId">fdsafds-68es-3615-a6f7-71427b983092</ac:parameter>
<ac:parameter ac:name="key">XYZ057-172</ac:parameter>
</ac:structured-macro>
您需要找出服务器名称, serverId &amp; JIRA问题密钥你自己。
这意味着原始卷曲看起来像这样:
curl -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page with a JIRA macro added:</p><ac:structured-macro ac:name="jira"><ac:parameter ac:name="server">Example JIRA</ac:parameter><ac:parameter ac:name="serverId">fdsafds-68es-3615-a6f7-71427b983092</ac:parameter><ac:parameter ac:name="key">XYZ057-172</ac:parameter></ac:structured-macro>","representation":"storage"}}}' http://localhost:8080/confluence/rest/api/content/
答案 1 :(得分:0)
在php中使用此代码,您可以创建Confluence Pages:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8090/rest/api/content/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"type\":\"page\",\"title\":\"inserttitle\",\"space\":{\"key\":\"insertspace\"},\"ancestors\":[{\"type\":\"page\",\"id\":insertancestor}],\"body\":{\"storage\":{\"value\":\"<p>This is a new page</p>\",\"representation\":\"storage\"}}}");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "insertusername" . ":" . "insertpassword");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>