Skip to content

Commit

Permalink
Merge pull request #78 from MicroFocus/domelian_story_1790311
Browse files Browse the repository at this point in the history
us#1790311: add ability to get list of branches and get info about default branch
  • Loading branch information
lazara3 authored Apr 28, 2022
2 parents 4fe9192 + 46e4573 commit ac9e4bb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

<properties>
<java.version>1.8</java.version>
<integrations.sdk.version>2.7.2.6</integrations.sdk.version>
<integrations.sdk.version>2.7.4.1</integrations.sdk.version>
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
<maven.compiler.plugin.version>1.8</maven.compiler.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ CIJobsList getJobList() {
buildConf = dtoFactory.newDTO(PipelineNode.class)
.setJobCiId(parseProject.getJobCiId(true))
.setName(project.getNameWithNamespace())
.setDefaultBranchName(project.getDefaultBranch())
.setMultiBranchType(MultiBranchType.MULTI_BRANCH_PARENT);

projectNames = projectNames + buildConf.getName()+",";
Expand All @@ -248,10 +249,11 @@ PipelineNode createStructure(String buildId, boolean isMultiBranchParent) {

ParsedPath project = new ParsedPath(buildId, gitLabApi, isMultiBranchParent? PathType.MULTI_BRUNCH : PathType.PIPELINE);
try {
gitLabApi.getProjectApi().getProject(project.getFullPathOfProject());
Project currentProject = gitLabApi.getProjectApi().getProject(project.getFullPathOfProject());
addWebHookToProject(project.getFullPathOfProject(),true);
return dtoFactory.newDTO(PipelineNode.class)
.setJobCiId(project.getJobCiId(isMultiBranchParent))
.setDefaultBranchName(currentProject.getDefaultBranch())
.setMultiBranchType(isMultiBranchParent ? MultiBranchType.MULTI_BRANCH_PARENT : MultiBranchType.MULTI_BRANCH_CHILD)
.setName(project.getNameWithNameSpaceForDisplayName())
.setParameters(getParameters(project));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import com.hp.octane.integrations.OctaneConfiguration;
import com.hp.octane.integrations.dto.DTOFactory;
import com.hp.octane.integrations.dto.configuration.CIProxyConfiguration;
import com.hp.octane.integrations.dto.general.CIBuildStatusInfo;
import com.hp.octane.integrations.dto.general.CIJobsList;
import com.hp.octane.integrations.dto.general.CIPluginInfo;
import com.hp.octane.integrations.dto.general.CIServerInfo;
import com.hp.octane.integrations.dto.general.*;
import com.hp.octane.integrations.dto.parameters.CIParameter;
import com.hp.octane.integrations.dto.parameters.CIParameters;
import com.hp.octane.integrations.dto.pipelines.PipelineNode;
import com.hp.octane.integrations.dto.scm.Branch;
import com.hp.octane.integrations.dto.snapshots.CIBuildResult;
import com.hp.octane.integrations.dto.snapshots.CIBuildStatus;
import com.hp.octane.integrations.dto.tests.*;
Expand Down Expand Up @@ -230,6 +228,37 @@ public void runPipeline(String jobCiId, CIParameters ciParameters) {
}
}

@Override
public CIBranchesList getBranchesList(String jobCiId, String filterBranchName) {
ParsedPath parsedPath = new ParsedPath(jobCiId, gitLabApi, PathType.PIPELINE);

try {
List<Branch> result = new ArrayList<>();
String path = parsedPath.getPathWithNameSpace();

List<Branch> branches = gitLabApi.getRepositoryApi().getBranches(path, filterBranchName)
.stream().map(branch -> dtoFactory.newDTO(Branch.class)
.setName(branch.getName())
.setInternalId(ParsedPath.convertBranchName(branch.getName())))
.collect(Collectors.toList());
result.addAll(branches);

List<Branch> tags = gitLabApi.getTagsApi().getTags(path, null, null, filterBranchName)
.stream().map(tag -> dtoFactory.newDTO(Branch.class)
.setName(tag.getName())
.setInternalId(ParsedPath.convertBranchName(tag.getName())))
.collect(Collectors.toList());
result.addAll(tags);

return dtoFactory.newDTO(CIBranchesList.class)
.setBranches(result);
} catch (GitLabApiException e) {
log.error("Failed to get list of branches", e);
throw new RuntimeException(e);
}
}


@Override
public InputStream getTestsResult(String jobFullName, String buildNumber) {
TestsResult result = dtoFactory.newDTO(TestsResult.class);
Expand Down

0 comments on commit ac9e4bb

Please sign in to comment.