Integrate YouTrack 7 With Your Favorite Tools

Here at JetBrains we’re often asked to integrate YouTrack with this or that popular tool: version control systems, project management and planning tools, instant messaging services, custom time tracking and billing platforms, you name it. While we’re implementing most popular requests ourselves it’s certainly not possible for the team to implement, maintain and test all these integrations. There are just too many of them.

An obvious approach would be to support third-party plugins, allowing independent vendors and community members to step up and fill the gap. The thing is, YouTrack has no plugin support at the moment. What it does support is a scripting API called Workflows. Starting with YouTrack 7.0, workflow API provides a REST client implementation, making it possible for your custom script to make network requests and receive responses. That feature alone opens a wide variety of options when it comes to integrating YouTrack with your favorite tool set.

Here goes a basic example demonstrating how to post an issue change to a third-party system and deal with the response:

Once someone reports a new issue, the script above is invoked. It takes the issue contents and sends it to a remote server, http://server.com/issueRegistry. When a server response is received, it’s added to the aforementioned issue as a comment.

Looks cool. How do I get started?

A workflow tutorial is a good thing to start with. Download YouTrack Workflow Editor and try playing around with tutorial examples. This should give you a grasp of basic workflow concepts, such as rule types and language syntax.

screenshot_2016-12-30_17-07-34

Note: It’s not necessary to download a new workflow editor release to use new language features. When it comes to specific API support, it’s the YouTrack server version that matters.

If you’re a workflow veteran, then you’ve probably guessed by now that stateless workflow rules are good at posting data to a remote system. This is where their ability to react to issue changes comes in handy.

The next thing you’ll need is a REST API of some sort, provided by a remote server. Popular web services and platforms tend to have API documentation published, so make sure to get a look at it before trying to implement the actual integration. For instance, Facebook graph API is described at https://developers.facebook.com/docs/graph-api.

Push-style integration example

Let’s try to implement an integration with Slack’s instant messaging platform. The idea behind it is that a team communicating in a chat would like to get notified if a new issue appears in the issue tracker.

Following our own advice, we start with Slack API reference to see if there’s a handle we can use to post new issue notifications to. It turns out one can register a bot user to post generated messages on one’s behalf. Having a bot user registered, we can now post messages to a channel:

Now, if we get a new issue posted, a slack channel will receive something like this:

slack

Awesome.

Pull-style integration example

The next example shows how one can fetch additional content for YouTrack issues from the outside world. When a Pastebin reference is posted to an issue, it would be nice to get the actual content and replace the original link.

What else can I do with this API?

One can expect all HTTP protocol basics to be covered by a workflow REST client API. The corresponding documentation page describes available functions and parameters, remote authentication and error handling. It’s always a good idea to verify server response code and handle erroneous scenarios accordingly.

Please give us your feedback! Try the workflow rest client out and let us know how it works for your team.

This entry was posted in features, how-to, newsletter and tagged , , , . Bookmark the permalink.

6 Responses to Integrate YouTrack 7 With Your Favorite Tools

  1. Matthias says:

    Do you still work on the .NET API?
    Cause i don’t find much about it and the issue object for example is incomplete i think.

    With best regards.

    • Hadi Hariri says:

      It’s not actively being developed, but I do believe some people are still using it. However it is open to PR’s.

  2. Ignacio Medina says:

    can i use doHttpPost in a javascript workflow? i need to post issue status to a private API.
    thank you

  3. Claudio Villalobos says:

    Hello, can you guys post an example of using postSync with the JS workflow API ?
    Tried everything I could think of, but cannot figure it out.

    Thanks!

    • Valerie Andrianova says:

      Hello Claudio,
      Sure, we’ll add examples to our documentation and will provide you with the link.
      Thanks,

Leave a Reply to Evgeny Naumenko Cancel reply

Your email address will not be published. Required fields are marked *