Skip to content
Open
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 @@ -81,6 +81,7 @@
private boolean triggerOnMergeRequest = true;
private boolean triggerOnlyIfNewCommitsPushed = false;
private boolean triggerOnPipelineEvent = false;
private boolean triggerOnFailedPipelineEvent = false;
private boolean triggerOnAcceptedMergeRequest = false;
private boolean triggerOnClosedMergeRequest = false;
private boolean triggerOnApprovedMergeRequest = false;
Expand Down Expand Up @@ -512,6 +513,15 @@
this.triggerOnPipelineEvent = triggerOnPipelineEvent;
}

public boolean getTriggerOnFailedPipelineEvent() {
return triggerOnFailedPipelineEvent;
}

@DataBoundSetter
public void setTriggerOnFailedPipelineEvent(boolean triggerOnFailedPipelineEvent) {
this.triggerOnFailedPipelineEvent = triggerOnFailedPipelineEvent;
}

Check warning on line 523 in src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 522-523 are not covered by tests

@DataBoundSetter
public void setPendingBuildName(String pendingBuildName) {
this.pendingBuildName = pendingBuildName;
Expand Down Expand Up @@ -588,7 +598,7 @@
triggerToBranchDeleteRequest,
triggerOpenMergeRequestOnPush,
skipWorkInProgressMergeRequest);
pipelineTriggerHandler = newPipelineHookTriggerHandler(triggerOnPipelineEvent);
pipelineTriggerHandler = newPipelineHookTriggerHandler(triggerOnPipelineEvent, triggerOnFailedPipelineEvent);
}

private void initializeBranchFilter() {
Expand Down
134 changes: 133 additions & 1 deletion src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
private final String finishedAt;
private final String buildDuration;
private final String commentAuthor;
private final Integer pipelineId;
private final Integer pipelineIid;
private final String pipelineSource;
private final String pipelineUrl;
private final String commitMessage;
private final String commitTitle;
private final String commitAuthorName;
private final String commitAuthorEmail;
private final String commitUrl;
private final String projectWebUrl;
private final String projectPathWithNamespace;

@GeneratePojoBuilder(withFactoryMethod = "*")
CauseData(
Expand Down Expand Up @@ -109,7 +120,18 @@
String createdAt,
String finishedAt,
String buildDuration,
String commentAuthor) {
String commentAuthor,
Integer pipelineId,
Integer pipelineIid,
String pipelineSource,
String pipelineUrl,
String commitMessage,
String commitTitle,
String commitAuthorName,
String commitAuthorEmail,
String commitUrl,
String projectWebUrl,
String projectPathWithNamespace) {
this.actionType = Objects.requireNonNull(actionType, "actionType must not be null.");
this.sourceProjectId = Objects.requireNonNull(sourceProjectId, "sourceProjectId must not be null.");
this.targetProjectId = Objects.requireNonNull(targetProjectId, "targetProjectId must not be null.");
Expand Down Expand Up @@ -155,6 +177,17 @@
this.finishedAt = finishedAt;
this.buildDuration = buildDuration;
this.commentAuthor = commentAuthor;
this.pipelineId = pipelineId;
this.pipelineIid = pipelineIid;
this.pipelineSource = pipelineSource;
this.pipelineUrl = pipelineUrl;
this.commitMessage = commitMessage;
this.commitTitle = commitTitle;
this.commitAuthorName = commitAuthorName;
this.commitAuthorEmail = commitAuthorEmail;
this.commitUrl = commitUrl;
this.projectWebUrl = projectWebUrl;
this.projectPathWithNamespace = projectPathWithNamespace;
}

@Exported
Expand Down Expand Up @@ -205,6 +238,17 @@
variables.put("finishedAt", finishedAt);
variables.put("duration", buildDuration);
variables.putIfNotNull("gitlabTriggerPhrase", triggerPhrase);
variables.putIfNotNull("gitlabPipelineId", pipelineId == null ? null : pipelineId.toString());

Check warning on line 241 in src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 241 is only partially covered, one branch is missing
variables.putIfNotNull("gitlabPipelineIid", pipelineIid == null ? null : pipelineIid.toString());

Check warning on line 242 in src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 242 is only partially covered, one branch is missing
variables.putIfNotNull("gitlabPipelineSource", pipelineSource);
variables.putIfNotNull("gitlabPipelineUrl", pipelineUrl);
variables.putIfNotNull("gitlabCommitMessage", commitMessage);
variables.putIfNotNull("gitlabCommitTitle", commitTitle);
variables.putIfNotNull("gitlabCommitAuthorName", commitAuthorName);
variables.putIfNotNull("gitlabCommitAuthorEmail", commitAuthorEmail);
variables.putIfNotNull("gitlabCommitUrl", commitUrl);
variables.putIfNotNull("gitlabProjectWebUrl", projectWebUrl);
variables.putIfNotNull("gitlabProjectPathWithNamespace", projectPathWithNamespace);
return variables;
}

Expand Down Expand Up @@ -413,198 +457,286 @@
return commentAuthor;
}

@Exported
public Integer getPipelineId() {
return pipelineId;
}

@Exported
public Integer getPipelineIid() {
return pipelineIid;
}

@Exported
public String getPipelineSource() {
return pipelineSource;
}

@Exported
public String getPipelineUrl() {
return pipelineUrl;
}

@Exported
public String getCommitMessage() {
return commitMessage;
}

@Exported
public String getCommitTitle() {
return commitTitle;
}

@Exported
public String getCommitAuthorName() {
return commitAuthorName;
}

@Exported
public String getCommitAuthorEmail() {
return commitAuthorEmail;
}

@Exported
public String getCommitUrl() {
return commitUrl;
}

@Exported
public String getProjectWebUrl() {
return projectWebUrl;
}

@Exported
public String getProjectPathWithNamespace() {
return projectPathWithNamespace;
}

String getShortDescription() {
return actionType.getShortDescription(this);
}

@Exported
public String getMergeRequestState() {
return mergeRequestState;
}

@Exported
public String getMergedByUser() {
return mergedByUser;
}

@Exported
public String getMergeRequestAssignee() {
return mergeRequestAssignee;
}

@Exported
public MergeRequest getMergeRequest() {
if (mergeRequestId == null) {
return null;
}

return new MergeRequest(
mergeRequestId,
mergeRequestIid,
mergeCommitSha,
sourceBranch,
targetBranch,
mergeRequestTitle,
sourceProjectId,
targetProjectId,
mergeRequestDescription,
mergeRequestState);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CauseData causeData = (CauseData) o;
return new EqualsBuilder()
.append(actionType, causeData.actionType)
.append(sourceProjectId, causeData.sourceProjectId)
.append(targetProjectId, causeData.targetProjectId)
.append(branch, causeData.branch)
.append(sourceBranch, causeData.sourceBranch)
.append(userName, causeData.userName)
.append(userUsername, causeData.userUsername)
.append(userEmail, causeData.userEmail)
.append(sourceRepoHomepage, causeData.sourceRepoHomepage)
.append(sourceRepoName, causeData.sourceRepoName)
.append(sourceNamespace, causeData.sourceNamespace)
.append(sourceRepoUrl, causeData.sourceRepoUrl)
.append(sourceRepoSshUrl, causeData.sourceRepoSshUrl)
.append(sourceRepoHttpUrl, causeData.sourceRepoHttpUrl)
.append(mergeCommitSha, causeData.mergeCommitSha)
.append(mergeRequestTitle, causeData.mergeRequestTitle)
.append(mergeRequestDescription, causeData.mergeRequestDescription)
.append(mergeRequestId, causeData.mergeRequestId)
.append(mergeRequestIid, causeData.mergeRequestIid)
.append(mergeRequestState, causeData.mergeRequestState)
.append(mergedByUser, causeData.mergedByUser)
.append(mergeRequestAssignee, causeData.mergeRequestAssignee)
.append(mergeRequestTargetProjectId, causeData.mergeRequestTargetProjectId)
.append(mergeRequestLabels, causeData.mergeRequestLabels)
.append(targetBranch, causeData.targetBranch)
.append(targetRepoName, causeData.targetRepoName)
.append(targetNamespace, causeData.targetNamespace)
.append(targetRepoSshUrl, causeData.targetRepoSshUrl)
.append(targetRepoHttpUrl, causeData.targetRepoHttpUrl)
.append(triggeredByUser, causeData.triggeredByUser)
.append(before, causeData.before)
.append(after, causeData.after)
.append(lastCommit, causeData.lastCommit)
.append(targetProjectUrl, causeData.targetProjectUrl)
.append(ref, causeData.getRef())
.append(isTag, causeData.getIsTag())
.append(sha, causeData.getSha())
.append(beforeSha, causeData.getBeforeSha())
.append(status, causeData.getStatus())
.append(stages, causeData.getStages())
.append(createdAt, causeData.getCreatedAt())
.append(finishedAt, causeData.getFinishedAt())
.append(buildDuration, causeData.getBuildDuration())
.append(commentAuthor, causeData.getCommentAuthor())
.append(pipelineId, causeData.getPipelineId())
.append(pipelineIid, causeData.getPipelineIid())
.append(pipelineSource, causeData.getPipelineSource())
.append(pipelineUrl, causeData.getPipelineUrl())
.append(commitMessage, causeData.getCommitMessage())
.append(commitTitle, causeData.getCommitTitle())
.append(commitAuthorName, causeData.getCommitAuthorName())
.append(commitAuthorEmail, causeData.getCommitAuthorEmail())
.append(commitUrl, causeData.getCommitUrl())
.append(projectWebUrl, causeData.getProjectWebUrl())
.append(projectPathWithNamespace, causeData.getProjectPathWithNamespace())
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(actionType)
.append(sourceProjectId)
.append(targetProjectId)
.append(branch)
.append(sourceBranch)
.append(userName)
.append(userUsername)
.append(userEmail)
.append(sourceRepoHomepage)
.append(sourceRepoName)
.append(sourceNamespace)
.append(sourceRepoUrl)
.append(sourceRepoSshUrl)
.append(sourceRepoHttpUrl)
.append(mergeCommitSha)
.append(mergeRequestTitle)
.append(mergeRequestDescription)
.append(mergeRequestId)
.append(mergeRequestIid)
.append(mergeRequestState)
.append(mergedByUser)
.append(mergeRequestAssignee)
.append(mergeRequestTargetProjectId)
.append(mergeRequestLabels)
.append(targetBranch)
.append(targetRepoName)
.append(targetNamespace)
.append(targetRepoSshUrl)
.append(targetRepoHttpUrl)
.append(triggeredByUser)
.append(before)
.append(after)
.append(lastCommit)
.append(targetProjectUrl)
.append(ref)
.append(isTag)
.append(sha)
.append(beforeSha)
.append(status)
.append(stages)
.append(createdAt)
.append(finishedAt)
.append(buildDuration)
.append(commentAuthor)
.append(pipelineId)
.append(pipelineIid)
.append(pipelineSource)
.append(pipelineUrl)
.append(commitMessage)
.append(commitTitle)
.append(commitAuthorName)
.append(commitAuthorEmail)
.append(commitUrl)
.append(projectWebUrl)
.append(projectPathWithNamespace)
.toHashCode();
}

@Override
public String toString() {
return new ToStringBuilder(this)
.append("actionType", actionType)
.append("sourceProjectId", sourceProjectId)
.append("targetProjectId", targetProjectId)
.append("branch", branch)
.append("sourceBranch", sourceBranch)
.append("userName", userName)
.append("userUsername", userUsername)
.append("userEmail", userEmail)
.append("sourceRepoHomepage", sourceRepoHomepage)
.append("sourceRepoName", sourceRepoName)
.append("sourceNamespace", sourceNamespace)
.append("sourceRepoUrl", sourceRepoUrl)
.append("sourceRepoSshUrl", sourceRepoSshUrl)
.append("sourceRepoHttpUrl", sourceRepoHttpUrl)
.append("mergeCommitSha", mergeCommitSha)
.append("mergeRequestTitle", mergeRequestTitle)
.append("mergeRequestDescription", mergeRequestDescription)
.append("mergeRequestId", mergeRequestId)
.append("mergeRequestIid", mergeRequestIid)
.append("mergeRequestState", mergeRequestState)
.append("mergedByUser", mergedByUser)
.append("mergeRequestAssignee", mergeRequestAssignee)
.append("mergeRequestTargetProjectId", mergeRequestTargetProjectId)
.append("mergeRequestLabels", mergeRequestLabels)
.append("targetBranch", targetBranch)
.append("targetRepoName", targetRepoName)
.append("targetNamespace", targetNamespace)
.append("targetRepoSshUrl", targetRepoSshUrl)
.append("targetRepoHttpUrl", targetRepoHttpUrl)
.append("triggeredByUser", triggeredByUser)
.append("before", before)
.append("after", after)
.append("lastCommit", lastCommit)
.append("targetProjectUrl", targetProjectUrl)
.append("ref", ref)
.append("isTag", isTag)
.append("sha", sha)
.append("beforeSha", beforeSha)
.append("status", status)
.append("stages", stages)
.append("createdAt", createdAt)
.append("finishedAt", finishedAt)
.append("duration", buildDuration)
.append("commentAuthor", commentAuthor)
.append("pipelineId", pipelineId)
.append("pipelineIid", pipelineIid)
.append("pipelineSource", pipelineSource)
.append("pipelineUrl", pipelineUrl)
.append("commitMessage", commitMessage)
.append("commitTitle", commitTitle)
.append("commitAuthorName", commitAuthorName)
.append("commitAuthorEmail", commitAuthorEmail)
.append("commitUrl", commitUrl)
.append("projectWebUrl", projectWebUrl)
.append("projectPathWithNamespace", projectPathWithNamespace)

Check warning on line 739 in src/main/java/com/dabsquared/gitlabjenkins/cause/CauseData.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 462-739 are not covered by tests
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ void changeBuildStatus(
List<Label> getLabels(String projectId);

List<Pipeline> getPipelines(String projectName);

List<MergeRequest> getCommitMergeRequests(String projectId, String sha);
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@
});
}

@Override
public List<MergeRequest> getCommitMergeRequests(final String projectId, final String sha) {
return execute(new GitLabOperation<List<MergeRequest>>() {
@Override
List<MergeRequest> execute(GitLabClient client) {
return client.getCommitMergeRequests(projectId, sha);

Check warning on line 370 in src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl/AutodetectingGitLabClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 367-370 are not covered by tests
}
});
}

private GitLabClient delegate(boolean reset) {
if (reset || delegate == null) {
delegate = autodetectOrDie();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ void acceptMergeRequest(
List<Label> getLabels(String projectId);

List<Pipeline> getPipelines(String projectName);

List<MergeRequest> getCommitMergeRequests(String projectId, String sha);
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,9 @@
public List<Pipeline> getPipelines(String projectName) {
return api.getPipelines(projectName);
}

@Override
public List<MergeRequest> getCommitMergeRequests(String projectId, String sha) {
return api.getCommitMergeRequests(projectId, sha);

Check warning on line 203 in src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl/ResteasyGitLabClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 203 is not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,11 @@ User updateUser(
@Path("/projects/{projectId}/pipelines")
@Override
List<Pipeline> getPipelines(@PathParam("projectId") @Encoded String projectId);

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/projects/{projectId}/repository/commits/{sha}/merge_requests")
@Override
List<MergeRequest> getCommitMergeRequests(
@PathParam("projectId") @Encoded String projectId, @PathParam("sha") @Encoded String sha);
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,11 @@ User updateUser(
@Path("/projects/{projectId}/pipelines")
@Override
List<Pipeline> getPipelines(@PathParam("projectId") @Encoded String projectId);

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/projects/{projectId}/repository/commits/{sha}/merge_requests")
@Override
List<MergeRequest> getCommitMergeRequests(
@PathParam("projectId") @Encoded String projectId, @PathParam("sha") @Encoded String sha);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

private String id;
private String message;
private String title;
private Date timestamp;
private String url;
private User author;
Expand All @@ -38,6 +39,14 @@
this.message = message;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

Check warning on line 48 in src/main/java/com/dabsquared/gitlabjenkins/gitlab/hook/model/Commit.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 43-48 are not covered by tests

public Date getTimestamp() {
return timestamp;
}
Expand Down
Loading
Loading