Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to dynamically add a component to an issue based on the different Github repos?

Connor Skiro
Contributor
August 17, 2023

I have an ask by a team that maintains a dozen Github repos which is:
1. When a Pull Request is created
2. THEN add a component to the issue based on the name of the repo

For context, I have created components for each of their repos (e.g., 'react-hello-world' is a component in the project and the name of a repo)

Is it feasible to grab the name of the repo and then use that same smart value to edit the Component field?

Or do I have to use a multi if-else statement to apply the correct components?

Screenshot 2023-08-17 at 9.58.27 AM.png

Note: {{repoName}} = {{pullRequest.destinationBranch.repository.name}}

1 answer

1 accepted

0 votes
Answer accepted
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

Hi @Connor Skiro - If the components match the name of the repo, the If/Else conditions will not be necessary.  Are you encountering any issues with your rule?

Connor Skiro
Contributor
August 17, 2023

I was able to get the if/else option to work, but I'm trying to avoid the if/else statements altogether.

Instead, I'm looking to add a component based on the GitHub repo name from the {{pullRequest}} smart value

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

Your rule looks good to me.  Is the audit log showing any errors?

Connor Skiro
Contributor
August 17, 2023

An error on my part, {{pullRequest.destinationBranch.repository.name}} returns github-account/react-hello-world so I need to figure out if there's another smart value that just returns the repository name or how to grab the text after the slash.

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2023

You could do this:

{{pullRequest.destinationBranch.repository.name.subStringAfter("/")}}
Like Stefan Salzl likes this
Connor Skiro
Contributor
August 17, 2023

@Mark Segall you are great, thank you for the assist! I appreciate it!

Like Mark Segall likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events