Hi All
I am using script runner plugin to get the issue key from repository branch.
I added the scriptable task in the bamboo job.
import com.atlassian.bamboo.variable.CustomVariableContext
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bamboo.build.JiraIssueResultsManager
import com.atlassian.bamboo.plan.PlanKey
import com.atlassian.sal.api.component.ComponentLocator
import java.util.regex.Pattern
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.atlassian.bamboo.user.BambooUserManagerImpl")
log.setLevel(Level.WARN)
def variableContext = ComponentLocator.getComponent(CustomVariableContext)
def planbranch = variableContext.getVariableContexts().get("planRepository.branchName")?.getValue()
log.warn "**************plankey is : $planbranch**************"
log :
**************plankey is : feature/TM-1-addition-of-2-numbers**************
I am getting the name of the branch . How to get the issue key (TM-1)from it (feature/TM-1-addition-of-2-numbers) using groovy script?
any suggestion would be appreciable
please help me
Regards
Sushma
Hi @Sushma ,
I am unsure of what you are trying to accomplish and perhaps you could elaborate a bit more.
If ALL branches in Bamboo follow the same pattern, e.g:
Then, you could continue on using regex (import java.util.regex.* as per your source-code) to parse/extract Jira's Issue Key from branch name.
If the name of the branch does not carry Jira's Issue Key, then you could use CachedPlanManager and getPlans(), iterating over all of plans looking for branches. Then, with this list of branches you can iterate over each branch (ImmutableChainBranch) and getLinkedJiraIssue()
Here is an example:
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bamboo.plan.cache.CachedPlanManager;
import com.atlassian.bamboo.plan.cache.ImmutableTopLevelPlan;
import com.atlassian.bamboo.plan.cache.ImmutablePlan;
import com.atlassian.bamboo.plan.cache.ImmutableChainBranch;
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger LOG = Logger.getLogger("com.onresolve");
LOG.setLevel(Level.INFO)
CachedPlanManager cachedPlanManager = ComponentLocator.getComponent(CachedPlanManager);
List<ImmutableTopLevelPlan> immutableTopLevelPlanList = cachedPlanManager.getPlans();
List<ImmutablePlan> immutablePlans = new ArrayList<>();
immutablePlans.addAll(immutableTopLevelPlanList);
for (ImmutablePlan plan : immutablePlans) {
LOG.info("plan :: " + plan.getKey());
List<ImmutableChainBranch> chainBranchList = cachedPlanManager.getBranchesForChain(plan);
for (ImmutableChainBranch branch: chainBranchList) {
if (branch.getLinkedJiraIssue() != null) {
LOG.info("branch :: " + branch.getKey());
LOG.info("jira issue :: " + branch.getLinkedJiraIssue())
}
}
}
It is important to notice that ScriptRunner for Bamboo (BETA) still in BETA version and Adaptavist has not updated the plugin to support latest Bamboo versions. So scripts made to version 6.6.1 (latest Bamboo version supported according to Atlassian's Marketplace) may not work in latest Bamboo versions.
Kind regards,
Rafael
Let me briefly explain my requirement .
As and when the user commit the code in the development branch(which is created from Jira Ex:"feature/<issuekey-summary>" ) of Bitbucket, bamboo should be capable of running the all "Tests" belongs to that particular issue and after successful build bamboo should be able to post result back to jira server by creating "Test Execution" and link it to the corresponding "Test Plan".
Can you suggest me how to achieve the above Integration ?
I am literally confused like how to start?, which plugins I make use of ?..or can I achieve this without installing any third party tools?
currently I am using
Bitbucket Server - v5.14.1
Bamboo Server - 6.9.1
Jira Server - v7.10.1
and one more thing, In Jira we are handling "Test Management" with the help of a third party tool called "X-ray Test Management for Jira".
So After getting the issue key from the development branch , I need to
Need help to implement this.Please help me
Regards
Sushma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sushma ,
Out-of-box you have Development Panel in Jira that once integrated with Bamboo will provide you with build result as an example. However, based on your 1st paragraph, the integration you are looking for is not ready to accommodate your needs straight from Atlassian products. Because of that, you will need to rely on 3rd party plugins and/or extend some of the functionalities.
Xray Test Management for Jira along with Xray for Jira Add-on for Bamboo (by Xpand IT) seem to be an option. Alternatively, Zephyr for Jira - Test Management (by Zephyr, a SmartBear company) among others available in Atlassian Marketplace
Perhaps, you should consider raising an inquire directly with those vendors, as they will be able to provide you with more information about their products, what is already available, how to make use of the it and perhaps what will become available in new releases.
Please, find below links to their support channel:
If you also agree, the latest comment relates to a different topic from the one described in your initial inquire "How to retrieve the jira issue key from the repository branch name in bamboo using Script runner?". Therefore, if we continue on this thread now commenting about this new topic, those who may be facing the same problem and/or seeking for the same resolution will find very difficult finding the information due to indexing.
As a suggestion, if a new topic is to be discussed there is an opportunity to raise a new inquire in the Atlassian Community, increasing the chances of someone with experience in Testing, Jira and Bamboo integration participate and contribute on your inquire.
Last but not least, based on the Atlassian Products versions you have mentioned, I would encourage you on having a look at Atlassian - Security Advisories as some of those products/versions have security vulnerabilities announced.
Kind regards,
Rafael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks alot for the suggestion.
As you mentioned in the last comment
"Xray Test Management for Jira along with Xray for Jira Add-on for Bamboo (by Xpand IT) seem to be an option"
we are decided to follow the above approach.
But my question is how to get the set of Tests from jira to Bamboo Server dynamically?
and
How to use those tests in the Xray tasks of Bamboo?
I think to do this we need one more third party tool like Script runner/Groovy for Bamboo etc to get the tests dynamically.
am I right?
This is where I am facing the issue like
so on...
and after getting the set of "Tests" ,how to put those "tests" in the "Xray taks" to run the test?
Your help would be appreciable
Thanks in advance
Regards
Sushma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.