![JAR search and dependency download from the Maven repository](/logo.png)
com.clarolab.bamboo.client.BambooResultClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bamboo-rest-api-client Show documentation
Show all versions of bamboo-rest-api-client Show documentation
This library allows to extract information from projects, plans and builds on Bamboo
package com.clarolab.bamboo.client;
import com.clarolab.bamboo.entities.BambooMain;
import com.clarolab.bamboo.entities.BambooResult;
import com.clarolab.bamboo.utils.Constants;
import lombok.Builder;
import lombok.Data;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class BambooResultClient extends BambooClient {
@Builder
public BambooResultClient(BambooApiClient bambooApiClient, int limitResults) {
super(bambooApiClient, limitResults);
}
public List getResultsForPlan(String planKey) throws Exception {
return getResults(Constants.BAMBOO_RESULT_ENDPOINT, planKey, -1);
}
public List getResultsForPlanFromStages(String projectKeyPlanKey) throws Exception {
return getResultsForPlanFromStages(projectKeyPlanKey, -1);
}
public List getResultsForPlanFromStages(String projectKeyPlanKey, int greaterThanBuildNumber) throws Exception {
return getResultsForPlanFromStagesWithBuildGreaterThan(projectKeyPlanKey, greaterThanBuildNumber);
}
private List getResultsForPlanFromStagesWithBuildGreaterThan(String projectKeyPlanKey, int greaterThanBuildNumber) throws Exception {
return getResults(Constants.BAMBOO_RESULT_WITH_STAGES_ENDPOINT, projectKeyPlanKey, greaterThanBuildNumber);
}
private List getResults(String endPoint, String key, int greaterThanBuildNumber) throws Exception {
List bambooResults;
if(greaterThanBuildNumber <= 0)
bambooResults = perform(String.format(endPoint, key, 0, getLimitResults()), BambooMain.class).getResults();
else
bambooResults = perform(String.format(endPoint, key, 0, getLimitResults()), BambooMain.class).getResults()
.stream().filter(result -> result.getBuildNumber() > greaterThanBuildNumber).collect(Collectors.toList());
bambooResults.forEach(bambooResult -> {
if(bambooResult.getArtifacts() != null && !bambooResult.getArtifacts().isEmpty())
bambooResult.getArtifacts().forEach(bambooArtifact -> bambooArtifact.setBambooApiClient(getBambooApiClient()));
if(bambooResult.getStages() != null && !bambooResult.getStages().isEmpty()){
bambooResult.getStages().forEach(stage -> {
if(stage.getResults() != null && !stage.getResults().isEmpty()){
stage.getResults().forEach(bambooResultOnstage -> {
if(bambooResultOnstage.getArtifacts() != null || !bambooResultOnstage.getArtifacts().isEmpty())
bambooResultOnstage.getArtifacts().forEach(bambooArtifact -> bambooArtifact.setBambooApiClient(getBambooApiClient()));
});
}
});
}
});
return bambooResults;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy