Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation to notify members when today is the start date of a Release?

Gordon Bissell March 13, 2024

I've been looking at Project Settings -> Automation for a company-managed Jira project, and I see numerous possible rules; such as sending a Slack message when a new version/release is created.

What I'd like to do is create a scheduled (daily) automation rule that loops through all unreleased versions in the current project, and send a slack message if the start date of a version matches the current date.

I can add a When: Scheduled block, then a For: block, but there's no option to iterate through versions (all the options appear to be related to issues).

Is there a way to essentially do:

FOR 9:00am each day
  FOR all versions in project
    IF version.startDate == today THEN send message

1 answer

1 accepted

1 vote
Answer accepted
Kalyan Sattaluri
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.
March 13, 2024

Hello @Gordon Bissell 

*EDITED*

Thinking again, Correct approach is to make a REST call to get Project Versions, loop through the result set and find your version of interest.

Cause even if you had Scriptunner or other add-on, you would need issues tagged to the version to be able to query against.

Gordon Bissell March 13, 2024

I use the Python Jira library to get data from issues, and I see there are functions to get version info from a project. The problem is that - I assume like using REST calls - that's all got to run externally to Jira, so I need some other server run the scheduled job.

Kalyan Sattaluri
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.
March 13, 2024

Within Jira automation, after your "Scheduled" trigger, you will do Action-> Send Web Request and make the call to get all project versions.

Once you have it, you can loop through and send your notification.

So to do this, select Send Web request Action, 

Then at the bottom of the same screen click "Validate", if you get 200 status in response with all versions in payload, I can share next steps on looping through response. 

 

 

Like Gordon Bissell likes this
Gordon Bissell March 14, 2024

I've tried that, but when the rule runs I get a 404 error (No project could be found with key 'xx').

From the authentication link (https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/#supply-basic-auth-headers) I've tried the same via a curl request, and that also gives me the same error. I've tried a few different project keys that are in our Jira instance, and also the numerical ID for one of the projects; and all give the same 404 error.

Via the Python jira library I can run a jira.projects() call and get a list (using the same user email, URL, and auth token).

Though I note that I get the same 404 error if I corrupt the auth token in my curl call, so maybe I'm using the "wrong" auth token.

Gordon Bissell March 14, 2024

Fixed it: for some reason the token I've been using for Python (created last year) isn't liked for some reason. With a newly created token I've got it successfully returning a list of all the versions in the project. Guidance on looping through the response would be greatly appreciated.

Kalyan Sattaluri
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.
March 14, 2024

Great, looping is the easy part. Your versions payload should look like below

 {
    "self": "https://trainjira002.atlassian.net/rest/api/3/version/10003",
    "id": "10003",
    "description": "MY DESCRIPTION 2",
    "name": "RELEASE 2",
    "archived": false,
    "released": false,
    "startDate": "2024-03-14",
    "releaseDate": "2024-03-19",
    "overdue": false,
    "userStartDate": "13/Mar/24",
    "userReleaseDate": "18/Mar/24",
    "projectId": 10000
  },

 

After your web request call is done, do an Advanced Branch. Its a For/Each type of Action so this does the looping for you.

In that section, choose smart value as {{webResponse.body}} and give a variable name, in my example variterate.

This section essentially loops through each block and once inside, you can access values through dot notation, such as variterate.startDate etc.

Continuing, Once inside, we do an If condition -> smart value check, to compare if  {{variterate.startDate}} equals {{now.jiraDate}}, if it passes, you can do your next steps, such as sending slack notification in your case...

 

I am sharing 2 screenshots below, one for advanced branch, another for if condition check..

image.png

 

image.png

 

As mentioned, for a block which passes the condition, you can access the values using dot notation... such as {{variterate.name}} etc in your slack notification..

Hope it helps and let me know if questions..

Like Gordon Bissell likes this
Gordon Bissell March 14, 2024

That's working well - many thanks!

Feels like there is actually quite a lot of power in the automation system so I'll dive a bit deeper into the docs to try to learn more.

Like Kalyan Sattaluri likes this
Kalyan Sattaluri
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.
March 14, 2024

Awesome. Yes, these options within automation (send web request especially) lets us accomplish a lot of use cases which we couldnt otherwise.

One suggestion if you havent already, in the "Send Web Request" action of yours, there should be a checkbox to "Delay next steps"..  Always choose that so your next steps arent executed until you have a response in hand.

If you have any clarifications please let me know..

Finally, if everything looks good, please consider accepting answer so others can benefit from the discussion in the future.. Thanks!

Like Gordon Bissell likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events