How do I setup a Jelly-script scheduled service to run once a day on weekdays only

Chris Kent
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2012

How do I setup a Jelly-script scheduled service to run once a day on weekdays only?

I have a script that gets the results of a pre-defined filter (issues which need immediate attention) and adds a comment which in turn will email the assignee as a reminder...

The only problem is that this runs every day, including weekends... In this day and age with smart phones, our developers don't want to be hassled on weekends (understandably)....

How can I setup a weekday schedule for a service runner?

Alternatively, is there a way that a filter returns no issues if run on a weekend? This would also stop the spam....

1 answer

1 accepted

0 votes
Answer accepted
Dave C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 3, 2012

Hey Chris,

if you would like to schedule services to run against JIRA with something like cron, I'd highly recommend using the APIs to run these tasks in JIRA rather than using Jelly Tags. You could, for example:

  • Have a shell script use the REST API to work through the required tasks.
  • Use the JIRA Command Line Interface. This does use the SOAP API, which is being deprecated so may not be the best solution for future-proofing. There may be future development for the CLI to use the REST API which I'm not aware of, however.

There's also a New Feature request to have better time handling implemented into the services within JIRA, under JRA-1865 - please vote and watch on that issue if you're interested in it.


Dave

Andrei [errno]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2012

+1 on JIRA CLI

Chris Kent
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2012

Hi Dave,

I have been reading about REST and bashing my head against a wall trying to get something to work, I have been trying to use curl on the command line and all it does is throw errors, either bash errors or http errors... Here is a sample attempt

curl -D- -u administrator:administrator -X POST --data "{"jql": "status=Open", "startAt": "0", "maxResults": "50", "fields": ["key","summary"]}" -H "Content-Type: application/json" http://127.0.0.1:8080/rest/api/2/search/
<br< a="">>

Now if I get something to work, what do I do with the results? How do I loop through all the returned values and add comments or change data in each issue?

Thanks

Chris

Dave C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 4, 2012

Hey Chris,

The easier path would probably be using the JIRA CLI - this is a whole set of scripts designed to use the SOAP API rather than writing one to target REST as required. Bob may be updating them to use REST.

Otherwise, first I'd recommend testing the REST calls with something like the REST Console in Chrome. This will help you isolate whether or not the REST call or the command line is causing the problem. As for going through the returned values, you'd need a wrapper script to parse the JSON. You could do it with Perl - here are some examples that should help:

Hope that helps! :)

Suggest an answer

Log in or Sign up to answer