Bamboo trigger - Multiple Repository

If I have multiple repositories (say of type Stash) added to a Bamboo Build plan and a repository polling trigger defined with more than one repository selected, is there a way to find in bamboo which repository commit triggered the build ?  

1 answer

This widget could not be displayed.

Hi Saugat,

 

Yes, you can do that. Use the below query to get the desired result.

 

SELECT 
BUILD_KEY,
BUILD_NUMBER,
BUILD_STATE,
BUILD_DATE,
COMMIT_FILE_NAME,
COMMIT_FILE_REIVISION,
NAME AS 'Repository Name',
COMMIT_COMMENT_CLOB AS COMMIT_COMMENT,
AUTHOR_EMAIL,
AUTHOR_NAME
FROM
buildresultsummary a,
repository_changeset b,
commit_files c,
repository_changeset d,
vcs_location e,
user_commit f,
author g
WHERE
a.BUILDRESULTSUMMARY_ID = b.BUILDRESULTSUMMARY_ID
AND e.vcs_location_id = d.vcs_location_id
AND f.COMMIT_REVISION = d.CHANGESET_ID
AND f.REPOSITORY_CHANGESET_ID = d.REPOSITORY_CHANGESET_ID
AND f.REPOSITORY_CHANGESET_ID = b.REPOSITORY_CHANGESET_ID
AND g.author_id = f.author_id
AND c.commit_id = f.commit_id;


Please note: The above query is built for MYSQL and you may have to change the syntax if any other database.

Please accept the answer if you find it's useful so that others can also take benefit from it.

 

Thanks,

Robhit

thanks...good info

But I need the repo name available during the execution of the plan (like through bamboo variable or something else) as the plan have some processing on the repo which triggered the build. I don't think querying Bamboo DB is a suitable option here.

 

 

 

   

There is a Bamboo generic repository variable "bamboo.planRepository.<position>.name" which could give you the name of the repository but it will always give you the name of the default linked repository to the plan.

https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html

Moreover, looking at your first question - "is there a way to find in bamboo which repository commit triggered the build ?"
Let's say you have 2 repo's "RepoA" and RepoB" and you commit changes to "RepoB" then, in this case, the complete build plan will be triggered because we have a repository polling trigger.

But, if the source code checkout task in the plan configuration is configured to use the "RepoA" then this question is not valid in this case because you commit changes to the "RepoB" and the "RepoA" is being checked out or else if you have multiple tasks to checkout multiple repositories then they all will be triggered by bamboo for checkout because the entire build plan is triggered.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

216 views 3 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you