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 field for setting context for pending step #159

Merged
merged 3 commits into from
Nov 23, 2016
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 @@ -11,6 +11,7 @@
import hudson.tasks.Builder;
import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.plugins.github.common.ExpandableMessage;
import org.jenkinsci.plugins.github.extension.status.GitHubStatusContextSource;
import org.jenkinsci.plugins.github.extension.status.StatusErrorHandler;
import org.jenkinsci.plugins.github.extension.status.misc.ConditionalResult;
import org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter;
Expand All @@ -35,6 +36,7 @@ public class GitHubSetCommitStatusBuilder extends Builder implements SimpleBuild
private static final ExpandableMessage DEFAULT_MESSAGE = new ExpandableMessage("");

private ExpandableMessage statusMessage = DEFAULT_MESSAGE;
private GitHubStatusContextSource contextSource = new DefaultCommitContextSource();

@DataBoundConstructor
public GitHubSetCommitStatusBuilder() {
Expand All @@ -47,6 +49,14 @@ public ExpandableMessage getStatusMessage() {
return statusMessage;
}

/**
* @return Context provider
* @since FIXME
*/
public GitHubStatusContextSource getContextSource() {
return contextSource;
}

/**
* @since 1.14.1
*/
Expand All @@ -55,6 +65,14 @@ public void setStatusMessage(ExpandableMessage statusMessage) {
this.statusMessage = statusMessage;
}

Copy link
Member

Choose a reason for hiding this comment

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

please add since FIXME javadoc tag, i'll fix actual version before release

/**
* @since FIXME
*/
@DataBoundSetter
public void setContextSource(GitHubStatusContextSource contextSource) {
this.contextSource = contextSource;
}

@Override
public void perform(@NonNull Run<?, ?> build,
@NonNull FilePath workspace,
Expand All @@ -64,7 +82,7 @@ public void perform(@NonNull Run<?, ?> build,
GitHubCommitStatusSetter setter = new GitHubCommitStatusSetter();
setter.setReposSource(new AnyDefinedRepositorySource());
setter.setCommitShaSource(new BuildDataRevisionShaSource());
setter.setContextSource(new DefaultCommitContextSource());
setter.setContextSource(contextSource);
setter.setErrorHandlers(Collections.<StatusErrorHandler>singletonList(new ShallowAnyErrorHandler()));

setter.setStatusResultSource(new ConditionalStatusResultSource(
Expand All @@ -79,6 +97,14 @@ public void perform(@NonNull Run<?, ?> build,
setter.perform(build, workspace, launcher, listener);
}


public Object readResolve() {
if (getContextSource() == null) {
setContextSource(new DefaultCommitContextSource());
}
return this;
}

@Extension
public static class Descriptor extends BuildStepDescriptor<Builder> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if (instance == null) {
instance = new GitHubSetCommitStatusBuilder()
}

f.dropdownDescriptorSelector(title: _('Commit context: '), field: 'contextSource')

f.advanced() {
f.entry(title: _('Build status message'), field: 'statusMessage') {
f.property()
Expand Down