Menu Close

JIRA To Omnifocus Script

This script logs into your JIRA and creates OmniFocus tasks for each of the JIRA items that are assigned to you, so they sync to your Omnifocus for iPhone, you only have to keep track of one inbox, etc. It only takes a tiny bit of setup.

Setting up

To set this up, do the following:

  1. Download the script and put it somewhere it will run
  2. Install the required gems (appscript, crypt, password) with gem install.
  3. Go to JIRA and create a saved filter with whatever settings you like. Note the filter ID.
  4. Go to the top of the jiratoomnifocus file and set it on the JIRA_FILTER_ID constant, and set the JIRA_BASE_URL to the URL of your JIRA installation.
  5. If you like to keep your system very secure, take a look at the security warning, below, at this time
  6. Run it. You will be asked to login the first time. After it’s done, note the new tasks on your Omnifocus. Delete a task and run it again to see it add it again without asking you for authentication.

You’re set up! Now you can put it on a cron line, like this one which sets it to run at office hours (use cron -e on Terminal for this):

0,10,20,30,40,50 7-18 * * * /yourdir/jiratoomnifocus > /yourdir//log/jira_to_omnifocus.log 2>&1

Congratulations! You now have only one inbox again. Let me know if you use it; I’d love to know of more ideas on how we can make it better/easier to setup.

Security Warning

The password for your JIRA account will be saved on a file on your computer called ~/.hackerdude/jira_credentials.yml. It is encrypted using blowfish using a constant key.

As long as both your jiratoomnifocus script and your credentials file are secured as (chmod 700 and owned by the user that will be running it on cron), you should be okay and secure (unless someone breaks into your account, in which case you have bigger problems than your JIRA access!). The crypt key used is a constant on the jiratoomnifocus script. Change the CRYPT_KEY key for any other random string of the same length and delete the jira_credentials.yml file (so it asks for your password again) and it will be recreated using your key the next time you start it.

18 Comments

  1. Alain

    Hi,

    Thanks for publishing this script!

    For me, it’s not really useful though, mainly for just one reason: When i move an issue from my omnifocus-inbox to a project, it will be reimportet by jiratoomnifocus next time it’s running, which leads to lots of duplicates.

    If that’s resolved, it would help a lot 🙂
    Alain

  2. Hackerdude

    Ah, Alain was right. I just uploaded a new version on the same URL that does take into account tasks in other sections of the file. You can now move the task to the folder and it won’t add duplicates.

    Thanks for trying it out, and let me know if there’s other features you want (patches also welcome).

  3. Alain

    Hi Hackerdude,

    thanks a lot for the patch, that was fast 🙂

    I have later learned, that one can have default contexts in projects, so when dragged the issues to a project, i just set the context like this and i circumvented the duplicates. but now it’s even better! i will try it out right on.

    What i’d really like if it would also set the estimated time and the due-date (if one is set in JIRA) 🙂

    I did some playing around with getting updated tasks back to JIRA. For now, i am able to update the estimated time and the due date. in my setup i also set the context in omnifocus to the same string as the username in JIRA. Like this i am able to reassign issues in JIRA (I will publish the script hopefully within the next days). Of course this is quite specific, but it would be cool if the importer supports that as well 🙂

    So far…
    Alain

  4. Joe Ramsey

    Thanks so much or the great work. Alain I’m going to try your script out next. It would be nice to get these integrated. I’ll work on it a bit as well

    I did have to download the getopt gem as well to get it to work

  5. Dan Brickley

    Ruby 1.9 seems unhappy…

    /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:47:in `|’: can’t convert String into Integer (TypeError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:47:in `block (2 levels) in setup_blowfish’
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:46:in `times’
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:46:in `block in setup_blowfish’
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:44:in `upto’
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:44:in `setup_blowfish’
    from /usr/local/lib/ruby/gems/1.9.1/gems/crypt-1.1.4/crypt/blowfish.rb:27:in `initialize’

  6. David Martinez

    I depend on some libraries, so 1.9 compatibility depends on the libraries’ compatibility.

    Crypt is not compatible with Ruby 1.9, but gem install crypt19 and it will get past that.

    It looks like there’s also an appscript problem calling name.get on ruby1.9. May just be my install though. Using ruby 1.8.X seems to work correctly.

  7. Gerd

    Thanks David! Just working. I got the tip from Omni support because I asked for the integration.
    Feature request (unfortunately I have no clue about Ruby): We have several projects in Jira. I set up a filter with my open tasks for all projects. So it would be perfect if there would be a chance to create the Omni-tasks in any kind of a project structure and not flat in the inbox. With this it would minimize manual work.
    A tip for using: it took me a while to figure out the ID for the filter since it is not displayed anywhere on the Jira pages (at least i couldn’t find it). But just use the filter and look on the Jira URL in your browser. The “requestID” is what you want.

  8. Zach

    I had to “sudo gem install activesupport –version < 2" in order to get this to work on my 10.6.7 machine, if anyone else is struggling.

  9. Ben

    Ruby refuses to install Appscript for me. Could you tell me which Ruby implementation you’re using that was happy to run Appscript (Oneclick, MacRuby, default Ruby instance, etc…)?

    Thanks

  10. Elliot

    In case anyone else is trying to install this on Lion (with a fairly virgin install of Ruby…I’m not a Ruby developer)

    sudo gem update –system
    sudo env ARCHFLAGS=”-arch x86_64″ gem install appscript
    sudo env ARCHFLAGS=”-arch x86_64″ gem install rb-appscript
    sudo env ARCHFLAGS=”-arch x86_64″ gem install crypt
    sudo env ARCHFLAGS=”-arch x86_64″ gem install password
    sudo gem install getopt
    sudo gem install activesupport -v ‘2.0.2’

    (that last line is required by the current version of the password gem, the latest version of active support (3) doesn’t seem to work with it.

    This got the script working for me in 10.7.1
    if you uncomment the line that reads “require ‘ruby-debug'” in an attempt to get more debug information, you will also need to run:

    sudo gem install ruby-debug

  11. Elliot

    A note on the comment I added above, the gem update at the beginning has two dashes in front of the word system (all others in the instructions are just one dash)

    I guess the comment system automatically changes a double dash into an em-dash (that dash looks a bit longer than the others)

  12. Benn

    On snowleopard I had to downgrade to rubygems 1.5.3 to get this script to work, though I still can’t store my username and password without an error.

    Also when I move a jira item out of my inbox and import again, duplicates of the items show up again in my inbox..

  13. Mike

    Yeah this is working for me except for the fact that it adds tasks back to the inbox that were filed according to my organization system. that’s going to become a problem…

  14. Alexander Sorokin

    Hey guys, can you add a license to your code/changes? Something like Apache 2.0 or BSD would be ideal. I’d like to use the code, stick it on github and polish it a bit, but I can’t do that w/o a license. Thanks!

Comments are closed.