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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,572 views 0 6
Read article

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