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

ChainCompletedEvent does not show branchName, prKey etc values

Balazs Galambos January 14, 2022

Dear Bamboo Dev

We have switched from BuildFinishedEvent to ChainCompletedEventHandler (https://docs.atlassian.com/atlassian-bamboo/2.7/com/atlassian/bamboo/event/ChainCompletedEvent.html, https://developer.atlassian.com/server/bamboo/bamboo-event-listeners/) to send some data from bamboo to a different server only after all build/ tests are successful for a given repository.

However it looks like this event handler does not always contain generic values like:

bamboo.planRepository.<position>.branch or bamboo.repository.pr.key

 

I have debugged code with 

@EventListener
public void myChainCompletedEvent(ChainCompletedEvent event) {
LOGGER.error("@@DEBUG myChainCompletedEvent.event.getChainExecution().isSuccessful()"+event.getChainExecution().isSuccessful());
LOGGER.error("@@DEBUG myChainCompletedEvent.getBuildContext"+event.getBuildContext());
LOGGER.error("@@DEBUG myChainCompletedEvent.event.getBuildContext().getCurrentResult().getCustomBuildData()"+event.getBuildContext().getCurrentResult().getCustomBuildData());
LOGGER.error("@@DEBUG myChainCompletedEvent.getPlanKey().getKey().toLowerCase()"+event.getPlanKey().getKey().toLowerCase());

if (event.getChainExecution().isSuccessful()) {
BuildContext buildContext = event.getBuildContext();
Map<String, String> customBuildData = buildContext.getCurrentResult().getCustomBuildData();
int buildNumber = buildContext.getBuildNumber();
if (acceptedToTest(event.getPlanKey().getKey().toLowerCase())) {
String branchName = customBuildData.get("planRepository.branchName");
String branchName1 = customBuildData.get("planRepository.1.branchName");
String branchName2 = customBuildData.get("planRepository.2.branchName");
String branchgitName = customBuildData.get("planRepository.branch");
String branchgitName1 = customBuildData.get("planRepository.1.branch");
String branchgitName2 = customBuildData.get("planRepository.2.branch");
String prKey = customBuildData.get("repository.pr.key");
String branchRevision = customBuildData.get("planRepository.revision");
String repositoryUrl = customBuildData.get("planRepository.repositoryUrl");
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..planRepository.branchName"+branchName);
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..planRepository.branchName"+branchName1);
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..planRepository.branchName"+branchName2);
LOGGER.error("@@DEBUG myChainCompletedEvent..git..planRepository.branch"+branchgitName);
LOGGER.error("@@DEBUG myChainCompletedEvent..git..planRepository.branch"+branchgitName1);
LOGGER.error("@@DEBUG myChainCompletedEvent..git..planRepository.branch"+branchgitName2);
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..repository.pr.key"+prKey);
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..planRepository.revision"+branchRevision);
LOGGER.error("@@DEBUG myChainCompletedEvent..generic..planRepository.repositoryUrl"+repositoryUrl);


//BuildInfo buildInfo = calculateBuildInfoData(buildNumber,branchName,repositoryUrl,branchRevision,prKey);
//InfoSenderQueues.addBuildToTest(buildInfo);
}
}
}

 but it shows in log:

`

ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent.event.getChainExecution().isSuccessful()true
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent.getBuildContextcom.atlassian.bamboo.v2.build.BuildContextImpl@68af0b1c
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent.event.getBuildContext().getCurrentResult().getCustomBuildData(){plan.storageTag=plan-652314331}
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent.getPlanKey().getKey().toLowerCase()rtb-nrb17131
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..planRepository.branchNamenull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..planRepository.branchNamenull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..planRepository.branchNamenull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..git..planRepository.branchnull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..git..planRepository.branchnull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..git..planRepository.branchnull
2022-01-14 15:18:51,412 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..repository.pr.keynull
2022-01-14 15:18:51,413 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..planRepository.revisionnull
2022-01-14 15:18:51,413 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-14] [DiffsAnalyzer] @@DEBUG myChainCompletedEvent..generic..planRepository.repositoryUrlnull

`

Is this a bug, or what explains that there is (in our case) ONE build plan which does not publish these variables in customBuildData?

How it can be fixed?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events