Bamboo trigger - Multiple Repository

Saugat Chowdhury October 21, 2017

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

0 votes
robhit
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2017

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

Saugat Chowdhury October 26, 2017

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.

 

 

 

   

robhit
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 27, 2017

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
TAGS
AUG Leaders

Atlassian Community Events