Skip to content

Use strategies from SCM to the build name job #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GitLabMergeRequestCauseData {
private Map<String, String> variables = new HashMap<>();

public GitLabMergeRequestCauseData(MergeRequestEvent mergeRequestEvent) {
this.variables.put("GITLAB_OBJECT_KIND", defaultString(mergeRequestEvent.OBJECT_KIND));
this.variables.put("GITLAB_OBJECT_KIND", defaultString(MergeRequestEvent.OBJECT_KIND));
this.variables.put("GITLAB_USER_NAME", defaultString(mergeRequestEvent.getUser().getName()));
this.variables.put("GITLAB_USER_USERNAME", defaultString(mergeRequestEvent.getUser().getUsername()));
this.variables.put("GITLAB_USER_AVATAR_URL", defaultString(mergeRequestEvent.getUser().getAvatarUrl()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GitLabPushCauseData {
private Map<String, String> variables = new HashMap<>();

public GitLabPushCauseData(PushEvent pushEvent) {
this.variables.put("GITLAB_OBJECT_KIND", defaultString(pushEvent.OBJECT_KIND));
this.variables.put("GITLAB_OBJECT_KIND", defaultString(PushEvent.OBJECT_KIND));
this.variables.put("GITLAB_AFTER", defaultString(pushEvent.getAfter()));
this.variables.put("GITLAB_BEFORE", defaultString(pushEvent.getBefore()));
this.variables.put("GITLAB_REF", defaultString(pushEvent.getRef()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GitLabTagPushCauseData {
private Map<String, String> variables = new HashMap<>();

public GitLabTagPushCauseData(TagPushEvent tagPushEvent) {
this.variables.put("GITLAB_OBJECT_KIND", defaultString(tagPushEvent.OBJECT_KIND));
this.variables.put("GITLAB_OBJECT_KIND", defaultString(TagPushEvent.OBJECT_KIND));
this.variables.put("GITLAB_AFTER", defaultString(tagPushEvent.getAfter()));
this.variables.put("GITLAB_BEFORE", defaultString(tagPushEvent.getBefore()));
this.variables.put("GITLAB_REF", defaultString(tagPushEvent.getRef()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static String getStatusName(final GitLabSCMSourceContext sourceContext, final St
if (revision instanceof BranchSCMRevision) {
type = "branch";
} else if (revision instanceof MergeRequestSCMRevision) {
type = getMrBuildName(fullDisplayName);
type = getMrBuildName((MergeRequestSCMRevision)revision);
} else if (revision instanceof GitTagSCMRevision) {
type = "tag";
} else {
Expand Down Expand Up @@ -137,8 +137,8 @@ static String getRevisionRef(final SCMRevision revision) {
return refName;
}

private static String getMrBuildName(final String buildName) {
return (buildName.contains("merge") ? "mr-merge" : "mr-head");
private static String getMrBuildName(final MergeRequestSCMRevision revision) {
return (revision.isMerge() ? "mr-merge" : "mr-head");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jenkins.plugins.git.GitTagSCMHead;
import jenkins.plugins.git.GitTagSCMRevision;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.MergeRequestApi;
import org.gitlab4j.api.models.MergeRequest;
Expand Down Expand Up @@ -44,7 +45,7 @@ public void should_set_merge_request_head_status_name() {
GitLabSCMSourceContext sourceContext = new GitLabSCMSourceContext(null, null);

BranchSCMHead targetHead = new BranchSCMHead("target");
MergeRequestSCMHead head = new MergeRequestSCMHead("head", 0, targetHead, null, null, null, null, null, null);
MergeRequestSCMHead head = new MergeRequestSCMHead("head", 0, targetHead, ChangeRequestCheckoutStrategy.HEAD, null, null, null, null, null);

BranchSCMRevision target = new BranchSCMRevision(targetHead, "target-hash");
BranchSCMRevision source = new BranchSCMRevision(new BranchSCMHead("source"), "source-hash");
Expand All @@ -63,7 +64,7 @@ public void should_set_merge_request_merge_status_name() {
GitLabSCMSourceContext sourceContext = new GitLabSCMSourceContext(null, null);

BranchSCMHead targetHead = new BranchSCMHead("target");
MergeRequestSCMHead head = new MergeRequestSCMHead("head", 0, targetHead, null, null, null, null, null, null);
MergeRequestSCMHead head = new MergeRequestSCMHead("head", 0, targetHead, ChangeRequestCheckoutStrategy.MERGE, null, null, null, null, null);

BranchSCMRevision target = new BranchSCMRevision(targetHead, "target-hash");
BranchSCMRevision source = new BranchSCMRevision(new BranchSCMHead("source"), "source-hash");
Expand Down