Skip to content

Commit

Permalink
Merge pull request #510 from tomasbjerre/master
Browse files Browse the repository at this point in the history
Adding gitlabMergeRequestTargetProjectId variable
  • Loading branch information
omehegan authored May 9, 2017
2 parents fee5f71 + c74f336 commit c92e972
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ These include:
* gitMergedByUser
* gitMergeRequestAssignee
* gitlabMergeRequestLastCommit
* gitlabMergeRequestTargetProjectId
* gitlabTargetBranch
* gitlabTargetRepoName
* gitlabTargetNamespace
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class CauseData {
private final String mergeRequestState;
private final String mergedByUser;
private final String mergeRequestAssignee;
private final Integer mergeRequestTargetProjectId;
private final String targetBranch;
private final String targetRepoName;
private final String targetNamespace;
Expand All @@ -55,9 +56,9 @@ public final class CauseData {
CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName,
String userEmail, String sourceRepoHomepage, String sourceRepoName, String sourceNamespace, String sourceRepoUrl,
String sourceRepoSshUrl, String sourceRepoHttpUrl, String mergeRequestTitle, String mergeRequestDescription, Integer mergeRequestId,
Integer mergeRequestIid, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl,
String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit, String targetProjectUrl,
String triggerPhrase, String mergeRequestState, String mergedByUser, String mergeRequestAssignee) {
Integer mergeRequestIid, Integer mergeRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace,
String targetRepoSshUrl, String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit,
String targetProjectUrl, String triggerPhrase, String mergeRequestState, String mergedByUser, String mergeRequestAssignee) {
this.actionType = checkNotNull(actionType, "actionType must not be null.");
this.sourceProjectId = checkNotNull(sourceProjectId, "sourceProjectId must not be null.");
this.targetProjectId = checkNotNull(targetProjectId, "targetProjectId must not be null.");
Expand All @@ -78,6 +79,7 @@ public final class CauseData {
this.mergeRequestState = mergeRequestState == null ? "" : mergeRequestState;
this.mergedByUser = mergedByUser == null ? "" : mergedByUser;
this.mergeRequestAssignee = mergeRequestAssignee == null ? "" : mergeRequestAssignee;
this.mergeRequestTargetProjectId = mergeRequestTargetProjectId;
this.targetBranch = checkNotNull(targetBranch, "targetBranch must not be null.");
this.targetRepoName = checkNotNull(targetRepoName, "targetRepoName must not be null.");
this.targetNamespace = checkNotNull(targetNamespace, "targetNamespace must not be null.");
Expand Down Expand Up @@ -108,6 +110,7 @@ public Map<String, String> getBuildVariables() {
variables.put("gitlabMergeRequestDescription", mergeRequestDescription);
variables.put("gitlabMergeRequestId", mergeRequestId == null ? "" : mergeRequestId.toString());
variables.put("gitlabMergeRequestIid", mergeRequestIid == null ? "" : mergeRequestIid.toString());
variables.put("gitlabMergeRequestTargetProjectId", mergeRequestTargetProjectId == null ? "" : mergeRequestTargetProjectId.toString());
variables.put("gitlabMergeRequestLastCommit", lastCommit);
variables.pufIfNotNull("gitlabMergeRequestState", mergeRequestState);
variables.pufIfNotNull("gitlabMergedByUser", mergedByUser);
Expand Down Expand Up @@ -191,6 +194,10 @@ public Integer getMergeRequestIid() {
return mergeRequestIid;
}

public Integer getMergeRequestTargetProjectId() {
return mergeRequestTargetProjectId;
}

public String getTargetBranch() {
return targetBranch;
}
Expand Down Expand Up @@ -277,6 +284,7 @@ public boolean equals(Object o) {
.append(mergeRequestState, causeData.mergeRequestState)
.append(mergedByUser, causeData.mergedByUser)
.append(mergeRequestAssignee, causeData.mergeRequestAssignee)
.append(mergeRequestTargetProjectId, causeData.mergeRequestTargetProjectId)
.append(targetBranch, causeData.targetBranch)
.append(targetRepoName, causeData.targetRepoName)
.append(targetNamespace, causeData.targetNamespace)
Expand Down Expand Up @@ -313,6 +321,7 @@ public int hashCode() {
.append(mergeRequestState)
.append(mergedByUser)
.append(mergeRequestAssignee)
.append(mergeRequestTargetProjectId)
.append(targetBranch)
.append(targetRepoName)
.append(targetNamespace)
Expand Down Expand Up @@ -349,6 +358,7 @@ public String toString() {
.append("mergeRequestState", mergeRequestState)
.append("mergedByUser", mergedByUser)
.append("mergeRequestAssignee", mergeRequestAssignee)
.append("mergeRequestTargetProjectId", mergeRequestTargetProjectId)
.append("targetBranch", targetBranch)
.append("targetRepoName", targetRepoName)
.append("targetNamespace", targetNamespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected CauseData retrieveCauseData(MergeRequestHook hook) {
.withMergeRequestState(hook.getObjectAttributes().getState().toString())
.withMergedByUser(hook.getUser() == null ? null : hook.getUser().getUsername())
.withMergeRequestAssignee(hook.getAssignee() == null ? null : hook.getAssignee().getUsername())
.withMergeRequestTargetProjectId(hook.getObjectAttributes().getTargetProjectId())
.withTargetBranch(hook.getObjectAttributes().getTargetBranch())
.withTargetRepoName(hook.getObjectAttributes().getTarget().getName())
.withTargetNamespace(hook.getObjectAttributes().getTarget().getNamespace())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected CauseData retrieveCauseData(NoteHook hook) {
.withMergeRequestDescription(hook.getMergeRequest().getDescription())
.withMergeRequestId(hook.getMergeRequest().getId())
.withMergeRequestIid(hook.getMergeRequest().getIid())
.withMergeRequestTargetProjectId(hook.getMergeRequest().getTargetProjectId())
.withTargetBranch(hook.getMergeRequest().getTargetBranch())
.withTargetRepoName(hook.getMergeRequest().getTarget().getName())
.withTargetNamespace(hook.getMergeRequest().getTarget().getNamespace())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private CauseData retrieveCauseData(PushHook hook, Project project, MergeRequest
.withMergeRequestDescription(mergeRequest.getDescription())
.withMergeRequestId(mergeRequest.getId())
.withMergeRequestIid(mergeRequest.getIid())
.withMergeRequestTargetProjectId(mergeRequest.getTargetProjectId())
.withTargetBranch(mergeRequest.getTargetBranch())
.withTargetRepoName(hook.getRepository().getName())
.withTargetNamespace(hook.getProject().getNamespace())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected CauseData retrieveCauseData(PushHook hook) {
.withMergeRequestState(null)
.withMergedByUser("")
.withMergeRequestAssignee("")
.withMergeRequestTargetProjectId(null)
.withTargetBranch(getTargetBranch(hook))
.withTargetRepoName("")
.withTargetNamespace("")
Expand Down

0 comments on commit c92e972

Please sign in to comment.