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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get issue key from commit message?

hi

I have developed bamboo plugin. I want to get issue key from commit message.

I get more issue key like abc-324, test-567, w-32

I only want to get one issue key which  has issue in jira

so I want to request this issue key to jira and find jira has this issue with key.

How can I code this method like: (any method, package or api)

public boolean findIssueWithKeyInJira(String key){

// request to jira and find issue

// if issue is found return true

// else return false

return null;

}

My regex pattern is :

public static final String ISSUE_REGEX_PATTERN = "([A-Z][A-Z0-9]+-[0-9]+)";

public static String getIssuesInCommits(List<CommitContext> commitContexts) {
StringBuilder stringBuilder = null;
Set<String> issueKeySet = new HashSet<>();

try {

for (CommitContext commitContext : commitContexts) {
String commitMessage = commitContext.getComment();
Pattern pattern = Pattern.compile(ISSUE_REGEX_PATTERN);
if (commitMessage.trim().equals("")) {
continue;
}
Matcher issueMatcher = pattern.matcher(commitMessage);
while (issueMatcher.find()) {
issueKeySet.add(issueMatcher.group());
}

}

if (!issueKeySet.isEmpty()) {
stringBuilder = new StringBuilder();
for (String issueKey : issueKeySet) {
stringBuilder.append(issueKey).append(",");
}
stringBuilder.setLength(stringBuilder.toString().length() - 1);
}

} catch (Exception e) {
stringBuilder = null;
}
return stringBuilder == null ? null : stringBuilder.toString();
}

1 answer

1 vote

Hey @metinbulak

This forum is not the best channel for development questions.

I would encourage you to post the same question at https://community.developer.atlassian.com/c/bamboo-development.

There you are more likely to reach Atlassian developers and other plugin developers which should have more background to support you.

I hope you get your answer soon from them.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

684 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you