Skip to content

Commit

Permalink
Merge pull request #74 from lazara3/master
Browse files Browse the repository at this point in the history
defect #1515261: Gitlab Pipelines triggered for branches containing a…
  • Loading branch information
lazara3 authored Mar 21, 2022
2 parents 5d348e5 + 11d431f commit e07b8d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
25 changes: 4 additions & 21 deletions src/main/java/com/microfocus/octane/gitlab/api/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@
import com.hp.octane.integrations.dto.events.MultiBranchType;
import com.hp.octane.integrations.dto.events.PhaseType;
import com.hp.octane.integrations.dto.parameters.CIParameter;
import com.hp.octane.integrations.dto.scm.SCMChange;
import com.hp.octane.integrations.dto.scm.SCMCommit;
import com.hp.octane.integrations.dto.scm.SCMData;
import com.hp.octane.integrations.dto.scm.SCMRepository;
import com.hp.octane.integrations.dto.scm.SCMType;
import com.hp.octane.integrations.dto.scm.*;
import com.hp.octane.integrations.dto.snapshots.CIBuildResult;
import com.microfocus.octane.gitlab.app.ApplicationSettings;
import com.microfocus.octane.gitlab.helpers.GitLabApiWrapper;
import com.microfocus.octane.gitlab.helpers.ParsedPath;
import com.microfocus.octane.gitlab.helpers.PathType;
import com.microfocus.octane.gitlab.helpers.PullRequestHelper;
import com.microfocus.octane.gitlab.helpers.VariablesHelper;
import com.microfocus.octane.gitlab.helpers.*;
import com.microfocus.octane.gitlab.model.ConfigStructure;
import com.microfocus.octane.gitlab.model.MergeRequestEventType;
import com.microfocus.octane.gitlab.services.OctaneServices;
Expand All @@ -38,11 +30,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -440,12 +428,7 @@ private String getCiFullName(JSONObject event) {
}

private String getConvertedBranchName(JSONObject event){
String convertedBranchName = getBranchName(event);

if(convertedBranchName!=null && convertedBranchName.contains("/")){
convertedBranchName = convertedBranchName.replaceFirst("/", ParsedPath.BRANCH_WITH_SLASH_SEPARATOR);
}
return convertedBranchName;
return ParsedPath.convertBranchName(getBranchName(event));
}

private String getBranchName(JSONObject event){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ public static String cutBranchFromPath(String s) {
return s.substring(0, s.lastIndexOf("/"));
}

public static String convertBranchName(String branchName){

if(branchName!=null && branchName.contains("/")){
branchName = branchName.replaceFirst("/", ParsedPath.BRANCH_WITH_SLASH_SEPARATOR);
}
return branchName;
}

public String getJobCiId(boolean isMultiBranchRoot){
String jobCiId = (PIPELINE_JOB_CI_ID_PREFIX + getPathWithNameSpace()).toLowerCase();
if(isMultiBranchRoot){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public CIBuildStatusInfo getJobBuildStatus(String jobCiId, String parameterName,
throw new RuntimeException("Failed to get the correct build status");
}
return dtoFactory.newDTO(CIBuildStatusInfo.class)
.setJobCiId("pipeline:" + parsedPath.getPathWithNameSpace() + "/" + chosenPipeline.get().getRef())
.setJobCiId(ParsedPath.PIPELINE_JOB_CI_ID_PREFIX + parsedPath.getPathWithNameSpace() + "/" + ParsedPath.convertBranchName(chosenPipeline.get().getRef()))
.setBuildStatus(buildStatus.get())
.setBuildCiId(getBuildCiId(chosenPipeline.get()))
.setParamName(parameterName)
Expand Down

0 comments on commit e07b8d8

Please sign in to comment.