Skip to content
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

Add two variable gitlabUserName and gitlabUserEmail #128

Merged
merged 5 commits into from
Dec 1, 2015
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 @@ -9,6 +9,7 @@
import org.gitlab.api.models.GitlabCommitStatus;
import org.gitlab.api.models.GitlabMergeRequest;
import org.gitlab.api.models.GitlabProject;
import org.gitlab.api.models.GitlabUser;

/**
* Represents for WebHook payload
Expand Down Expand Up @@ -87,9 +88,9 @@ public static class ObjectAttributes {

private Integer sourceProjectId;

private Integer authorId;
private User author;

private Integer assigneeId;
private User assignee;

private String title;

Expand Down Expand Up @@ -161,20 +162,34 @@ public void setSourceProjectId(Integer sourceProjectId) {
this.sourceProjectId = sourceProjectId;
}

public Integer getAuthorId() {
return authorId;
public User getAuthor() {
return author;
}

public void setAuthorId(Integer authorId) {
this.authorId = authorId;
public void setAuthor(User author) {
this.author = author;
}

public Integer getAssigneeId() {
return assigneeId;
public void setAuthor(GitlabUser author) {
this.author = new User();
this.author.setId(author.getId());
this.author.setEmail(author.getEmail());
this.author.setName(author.getName());
}

public void setAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
public User getAssignee() {
return assignee;
}

public void setAssignee(User assignee) {
this.assignee = assignee;
}

public void setAssignee(GitlabUser assignee) {
this.assignee = new User();
this.assignee.setId(assignee.getId());
this.assignee.setEmail(assignee.getEmail());
this.assignee.setName(assignee.getName());
}

public String getTitle() {
Expand Down Expand Up @@ -339,5 +354,40 @@ public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class User {

private Integer id;

private String name;

private String email;

public User() {
}

public Integer getId() { return id;}

public void setId(Integer id) { this.id = id; }

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ private Action[] createActions(GitLabPushRequest req) {
values.put("gitlabBranch", new StringParameterValue("gitlabBranch", branch));

values.put("gitlabActionType", new StringParameterValue("gitlabActionType", "PUSH"));
values.put("gitlabUserName", new StringParameterValue("gitlabUserName", req.getCommits().get(0).getAuthor().getName()));
values.put("gitlabUserEmail", new StringParameterValue("gitlabUserEmail", req.getCommits().get(0).getAuthor().getEmail()));
values.put("gitlabMergeRequestTitle", new StringParameterValue("gitlabMergeRequestTitle", ""));
values.put("gitlabMergeRequestId", new StringParameterValue("gitlabMergeRequestId", ""));
values.put("gitlabMergeRequestAssignee", new StringParameterValue("gitlabMergeRequestAssignee", ""));

LOGGER.log(Level.INFO, "Trying to get name and URL for job: {0}", job.getName());
String sourceRepoName = getDesc().getSourceRepoNameDefault(job);
Expand Down Expand Up @@ -336,6 +341,15 @@ private Action[] createActions(GitLabMergeRequest req) {
values.put("gitlabSourceBranch", new StringParameterValue("gitlabSourceBranch", getSourceBranch(req)));
values.put("gitlabTargetBranch", new StringParameterValue("gitlabTargetBranch", req.getObjectAttribute().getTargetBranch()));
values.put("gitlabActionType", new StringParameterValue("gitlabActionType", "MERGE"));
if (req.getObjectAttribute().getAuthor() != null) {
values.put("gitlabUserName", new StringParameterValue("gitlabUserName", req.getObjectAttribute().getAuthor().getName()));
values.put("gitlabUserEmail", new StringParameterValue("gitlabUserEmail", req.getObjectAttribute().getAuthor().getEmail()));
}
values.put("gitlabMergeRequestTitle", new StringParameterValue("gitlabMergeRequestTitle", req.getObjectAttribute().getTitle()));
values.put("gitlabMergeRequestId", new StringParameterValue("gitlabMergeRequestId", req.getObjectAttribute().getIid().toString()));
if (req.getObjectAttribute().getAssignee() != null) {
values.put("gitlabMergeRequestAssignee", new StringParameterValue("gitlabMergeRequestAssignee", req.getObjectAttribute().getAssignee().getName()));
}


LOGGER.log(Level.INFO, "Trying to get name and URL for job: {0}", job.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ protected void buildOpenMergeRequests(GitLabPushTrigger trigger, Integer project
newReq.setObject_kind("merge_request");
newReq.setObjectAttribute(new GitLabMergeRequest.ObjectAttributes());
if (mr.getAssignee() != null)
newReq.getObjectAttribute().setAssigneeId(mr.getAssignee().getId());
newReq.getObjectAttribute().setAssignee(mr.getAssignee());
if (mr.getAuthor() != null)
newReq.getObjectAttribute().setAuthorId(mr.getAuthor().getId());
newReq.getObjectAttribute().setAuthor(mr.getAuthor());
newReq.getObjectAttribute().setDescription(mr.getDescription());
newReq.getObjectAttribute().setId(mr.getId());
newReq.getObjectAttribute().setIid(mr.getIid());
Expand Down