diff --git a/zulip/integrations/jira/doc.md b/zulip/integrations/jira/doc.md deleted file mode 100644 index 96d97186c..000000000 --- a/zulip/integrations/jira/doc.md +++ /dev/null @@ -1,71 +0,0 @@ -*If you are running Jira version 5.2 or greater, or using the hosted -Jira provided by Atlassian, we recommend using the -[web-hook method](./jira) above instead. This plugin supports older -versions of Jira.* - -{!create-channel.md!} - -### Plugin mechanism - -{!download-python-bindings.md!} - -#### Plugin installation - -The Jira integration plugin requires two Jira plugins. Please install -the following plugins using the **Universal Plugin Manager** in your -Jira installation: - -* [Script Runner Plugin][script-runner] -* [SSL Plugin][ssl-plugin] - -[script-runner]: https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner -[ssl-plugin]: https://marketplace.atlassian.com/plugins/com.atlassian.jira.plugin.jirasslplugin - -#### SSL setup - -As Zulip is using a StartCOM SSL certificate that is not recognized by -default in the Java installation shipped with Jira, you will need to -tell Jira about the certificate. - -1. Navigate to **Administration > System > Configure SSL** and in the - **Import SSL Certificates** field, enter `{{ api_url }}`. - -2. After clicking **Save Certificates**, follow the on-screen - instructions and restart Jira for it to recognize the proper - certificates. - -#### Zulip integration - -1. Copy the folder `integrations/jira/org/` (from the tarball you - downloaded above) to your Jira `classes` folder. For self-contained - Jira installations, this will be `atlassian-jira/WEB-INF/classes/`, - but this may be different in your deployment. - -2. Edit the constants at the top of - `org/zulip/jira/ZulipListener.groovy` and fill them with the - appropriate values: - -``` Python -String zulipEmail = "jira-notifications-bot@example.com" -String zulipAPIKey = "0123456789abcdef0123456789abcdef" -String zulipStream = "jira" -String issueBaseUrl = "https://jira.COMPANY.com/browse/" -``` - -3. On the **Administrators** page, navigate to - **Plugins > Other > Script Listeners**. - -4. In the **Add Listener** section, click on the **Custom Listener** - option. Select the events you wish the Zulip integration to fire for, - and the projects you wish Zulip to be notified for. - -5. In the **Name of groovy class** field, enter - `org.zulip.jira.ZulipListener`. - -6. Click **Add Listener**, and Jira will now notify your Zulip of - changes to your issues! Updates from Jira will be sent to the stream - you've configured. - -{!congrats.md!} - -![Jira bot message](/static/images/integrations/jira-plugin/001.png) diff --git a/zulip/integrations/jira/org/humbug/jira/ZulipListener.groovy b/zulip/integrations/jira/org/humbug/jira/ZulipListener.groovy deleted file mode 100644 index 52b4b93d5..000000000 --- a/zulip/integrations/jira/org/humbug/jira/ZulipListener.groovy +++ /dev/null @@ -1,145 +0,0 @@ -package org.zulip.jira - -import static com.atlassian.jira.event.type.EventType.* - -import com.atlassian.jira.event.issue.AbstractIssueEventListener -import com.atlassian.jira.event.issue.IssueEvent - -import java.util.logging.Level -import java.util.logging.Logger - -import org.apache.commons.httpclient.HttpClient -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.methods.PostMethod -import org.apache.commons.httpclient.NameValuePair - -class ZulipListener extends AbstractIssueEventListener { - Logger LOGGER = Logger.getLogger(ZulipListener.class.getName()); - - // The email address of one of the bots you created on your Zulip settings page. - String zulipEmail = "" - // That bot's API key. - String zulipAPIKey = "" - - // What stream to send messages to. Must already exist. - String zulipStream = "jira" - - // The base JIRA url for browsing - String issueBaseUrl = "https://jira.COMPANY.com/browse/" - - // Your zulip domain - String base_url = "https://zulip.example.com/" - - @Override - void workflowEvent(IssueEvent event) { - processIssueEvent(event) - } - - String processIssueEvent(IssueEvent event) { - String author = event.user.displayName - String issueId = event.issue.key - String issueUrl = issueBaseUrl + issueId - String issueUrlMd = String.format("[%s](%s)", issueId, issueBaseUrl + issueId) - String title = event.issue.summary - String subject = truncate(String.format("%s: %s", issueId, title), 60) - String assignee = "no one" - if (event.issue.assignee) { - assignee = event.issue.assignee.name - } - String comment = ""; - if (event.comment) { - comment = event.comment.body - } - - String content; - - // Event types: - // https://docs.atlassian.com/jira/5.0/com/atlassian/jira/event/type/EventType.html - // Issue API: - // https://docs.atlassian.com/jira/5.0/com/atlassian/jira/issue/Issue.html - switch (event.getEventTypeId()) { - case ISSUE_COMMENTED_ID: - content = String.format("%s **updated** %s with comment:\n\n> %s", - author, issueUrlMd, comment) - break - case ISSUE_CREATED_ID: - content = String.format("%s **created** %s priority %s, assigned to @**%s**: \n\n> %s", - author, issueUrlMd, event.issue.priorityObject.name, - assignee, title) - break - case ISSUE_ASSIGNED_ID: - content = String.format("%s **reassigned** %s to **%s**", - author, issueUrlMd, assignee) - break - case ISSUE_DELETED_ID: - content = String.format("%s **deleted** %s!", - author, issueUrlMd) - break - case ISSUE_RESOLVED_ID: - content = String.format("%s **resolved** %s as %s:\n\n> %s", - author, issueUrlMd, event.issue.resolutionObject.name, - comment) - break - case ISSUE_CLOSED_ID: - content = String.format("%s **closed** %s with resolution %s:\n\n> %s", - author, issueUrlMd, event.issue.resolutionObject.name, - comment) - break - case ISSUE_REOPENED_ID: - content = String.format("%s **reopened** %s:\n\n> %s", - author, issueUrlMd, comment) - break - default: - return - } - - sendStreamMessage(zulipStream, subject, content) - } - - String post(String method, NameValuePair[] parameters) { - PostMethod post = new PostMethod(zulipUrl(method)) - post.setRequestHeader("Content-Type", post.FORM_URL_ENCODED_CONTENT_TYPE) - // TODO: Include more useful data in the User-agent - post.setRequestHeader("User-agent", "ZulipJira/0.1") - try { - post.setRequestBody(parameters) - HttpClient client = new HttpClient() - client.executeMethod(post) - String response = post.getResponseBodyAsString() - if (post.getStatusCode() != HttpStatus.SC_OK) { - String params = "" - for (NameValuePair pair: parameters) { - params += "\n" + pair.getName() + ":" + pair.getValue() - } - LOGGER.log(Level.SEVERE, "Error sending Zulip message:\n" + response + "\n\n" + - "We sent:" + params) - } - return response; - } catch (IOException e) { - throw new RuntimeException(e) - } finally { - post.releaseConnection() - } - } - - String truncate(String string, int length) { - if (string.length() < length) { - return string - } - return string.substring(0, length - 3) + "..." - } - - String sendStreamMessage(String stream, String subject, String message) { - NameValuePair[] body = [new NameValuePair("api-key", zulipAPIKey), - new NameValuePair("email", zulipEmail), - new NameValuePair("type", "stream"), - new NameValuePair("to", stream), - new NameValuePair("subject", subject), - new NameValuePair("content", message)] - return post("send_message", body); - } - - String zulipUrl(method) { - return base_url.replaceAll("/+$", "") + "/api/v1/" + method - } -} diff --git a/zulip/integrations/jira/requirements.txt b/zulip/integrations/jira/requirements.txt deleted file mode 100644 index e69de29bb..000000000