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

Implement the DSL for commentFilePath to fix #514 #709

Merged
merged 8 commits into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ job('upstreamJob') {
permitAll()
autoCloseFailedPullRequests()
displayBuildErrorsOnDownstreamBuilds()
commentFilePath("relative/path/to/file")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, isn't this changed now according to this: #637 (comment)

@bjoernhaeuser ?

whiteListTargetBranches(['master','test', 'test2'])
blackListTargetBranches(['master','test', 'test2'])
whiteListLabels(['foo', 'bar'])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jenkinsci.plugins.ghprb.jobdsl;

import javaposse.jobdsl.dsl.Context;

class GhprbCommentFilePathContext implements Context {
private String commentFilePath;

public String getCommentFilePath() {
return commentFilePath;
}

/**
* sets the path to the comment file
*/
public void commentFilePath(String commentFilePath) {
this.commentFilePath = commentFilePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
import org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate;
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus;
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbCommentFile;
import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus;

import java.util.ArrayList;
Expand Down Expand Up @@ -41,6 +42,16 @@ void buildStatus(Runnable closure) {
extensions.add(new GhprbBuildStatus(context.getCompletedStatus()));
}

/**
* Adds comment file path handling
*/
void commentFilePath(Runnable closure) {
GhprbCommentFilePathContext context = new GhprbCommentFilePathContext();
ContextExtensionPoint.executeInContext(closure, context);

extensions.add(new GhprbCommentFile(context.getCommentFilePath()));
}

/**
* Overrides global settings for cancelling builds when a PR was updated
*/
Expand Down