Forums

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

Jira automation get all project components

Ivan Shtanichev
Contributor
November 4, 2021

Hi,

I'm fairly new to Atlassian community, apologies if this has been asked before.

Our specific use case is when summary is created or updated, check if the summary contains any components that exist in the project and if it does then add those components to the ticket, thus essentially automating the addition of components based on the summary. Current workaround is to maintain a static array (as variable) of all project components and branch on that array to check if summary contains those strings. We would like to be able to pull all project components into automation dynamically, so we don't have to maintain a manual list. So my question is how can we use Jira automation to get a list of all components in a given project?

Thanks.

1 answer

1 accepted

3 votes
Answer accepted
Bill Sheboy
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.
November 4, 2021

Hi @Ivan Shtanichev 

To do that dynamically, you could call the REST API function from the rule using a web request and then parse the response using list and text functions to get the component list.

This will slow down the rule, perhaps by several seconds.

Kind regards,
Bill

Ivan Shtanichev
Contributor
November 8, 2021

Hi @Bill Sheboy

Many thanks for your reply.

Your suggestion has worked a treat!

I have now added an action 'Send web request' to my rule with a 'Web Request URL': https://<company>.atlassian.net/rest/api/3/project/{{project.key}}/components where I am using smart value {{project.key}} to get the project key dynamically. I am then adding 'Advanced branch' for 'Smart value': {{webResponse.body.name.split(", ")}} which enables me to iterate and perform actions on each component in the project, which is exactly what I wanted.

My only remaining question is whether there is any way that this web request can be performed as the user who triggered the rule? Because currently in the web request I am adding 'Authorization' in the Headers with a basic token of a Jira admin account, I would prefer if the web service call can be made using credentials of the triggering user, as they will have access to see components in target project anyway. Just so Jira admin token is not exposed unnecessarily.

Thanks,

Ivan

Bill Sheboy
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.
November 8, 2021

Hi Ivan,

I am glad to learn that helped.  At this time I do not believe there is another way to add authorization; there are a few suggestions/requests in the Code Barrel (now part of Atlassian) backlog to add that feature.

Kind regards,
Bill

Ivan Shtanichev
Contributor
November 9, 2021

Thanks Bill, I will stick with as is basic token Authorization for now in that case.

Like Bill Sheboy likes this
Bill Sheboy
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.
November 11, 2021

Thanks for that link, Ivan.

Although I am unclear how they would implement that without adding/linking the stored information for the REST API tokens to the Jira user accounts.  As it, the credentials would only be visible to the project admin for a rule and site admins.  Let's see how that one progresses.

Kind regards,
Bill

Ivan Shtanichev
Contributor
November 11, 2021

Thanks, yes, I guess Jira would somehow need to pass through the credentials of the Jira user to the API, which might be challenging, but if achieved would be quite a nice feature. Yes, in a single project scenario credentials would only be visible to admins of that project and Jira admins, but if the rule is global then those credentials are visible to all project admins, which is not so good.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer