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

[JENKINS-71332] Handle https://issues.jenkins.io/browse/JENKINS-71332… #49

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
@@ -1,11 +1,11 @@
package com.tikal.hudson.plugins.notification;

import com.google.common.collect.ImmutableSet;
import hudson.Extension;
import hudson.FilePath;
import hudson.Util;
import hudson.model.Run;
import hudson.model.TaskListener;
import org.eclipse.collections.impl.factory.Sets;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepContext;
Expand All @@ -14,13 +14,12 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.io.Serializable;
import java.util.Objects;
import java.util.Set;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

public class NotifyStep extends Step implements Serializable {
private static final long serialVersionUID = -2818860651754465006L;

Expand All @@ -46,7 +45,7 @@ public String getPhase() {
}

@DataBoundSetter
public void setPhase(@CheckForNull String phase) {
public void setPhase(@CheckForNull final String phase) {
this.phase = Util.fixEmpty(phase);
}

Expand All @@ -59,17 +58,12 @@ public String getLoglines() {
}

@DataBoundSetter
public void setLoglines(@CheckForNull String loglines) {
public void setLoglines(@CheckForNull final String loglines) {
this.loglines = Util.fixEmpty(loglines);
}

/**
* Creates a new instance of {@link NotifyStep}.
*/
@DataBoundConstructor
public NotifyStep() {
super();

// empty constructor required for Stapler
}

Expand All @@ -93,7 +87,7 @@ static class Execution extends StepExecution {

@Override
public boolean start() throws Exception {
String logLines = notifyStep.getLoglines();
final String logLines = notifyStep.getLoglines();

Phase.NONE.handle(Objects.requireNonNull(getContext().get(Run.class)), getContext().get(TaskListener.class), System.currentTimeMillis(), true,
notifyStep.getNotes(), Integer.parseInt(logLines != null ? logLines : "0"), Phase.valueOf(notifyStep.getPhase()));
Expand Down Expand Up @@ -122,9 +116,12 @@ public String getDisplayName() {
}

@Override
/*
Made use of implementation of
@see org.jenkinsci.plugins.workflow.steps.scm.SCMStep
*/
public Set<? extends Class<?>> getRequiredContext() {
return Sets.immutable.of(FilePath.class, FlowNode.class, Run.class, TaskListener.class)
.castToSet();
return ImmutableSet.of(Run.class, FilePath.class, TaskListener.class, FlowNode.class);
}
}
}
Loading