Forums

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

How do I get the repository name from smart value without the OWNER part?

Al Ma February 28, 2022

Hi all,

I'm trying to configure a JIRA automation rule where whenever a branch and/or commit is linked to an issue, a label would be added using the name of the repository.

The rule is working great when a commit is linked however when a branch is linked the name of the repository contains the OWNER part of the url.

The problem is that if the branch and commit both link to the same issue, it will create two labels using the repo name, but one of them contains OWNER/

Is there a way I can retrieve the name of the repository from {{branch.repository}} WITHOUT the OWNER part?

For example:

Given repository:
https://github.com/OWNER/my-test-repo

When commit created:
{{commit.repository}} = my-test-repo
Label added: my-test-repo

When branch created:
{{branch.repository}} = OWNER/my-test-repo
Label added: OWNER/my-test-repo

1 answer

1 accepted

2 votes
Answer accepted
Stefan Salzl
Community Champion
February 28, 2022

Hi @Al Ma ,

Please try the following option (worked on my side):

{{branch.repository.name.substringAfter("/")}}

 

image.png

Hope this solves the problem.

Best
Stefan

Al Ma February 28, 2022

That solved it, thanks Stefan!

Like Stefan Salzl likes this
Stefan Salzl
Community Champion
February 28, 2022

AWESOME!!!! 💪

Glad to know it works now 😉

Like Al Ma likes this
Brian Schaeffer April 2, 2025

I am fighting the same issue now - that command does not seem to work in Cloud for me.  Is there an updated smart value for this?

Stefan Salzl
Community Champion
April 9, 2025

Hi @Brian Schaeffer 

That screenshot was from Cloud version.

Could you please describe your whole use case as well as screenshots of you automation rule? 

Thanks in advance

best

stefan

Brian Schaeffer April 11, 2025

It is working now, can't say I did anything to fix it, but I may have and an extra space or character in there somehow.  Thank you for being willing to help.

Suggest an answer

Log in or Sign up to answer