forked from splunk/splunkforjenkins
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename sendSplunk to sendSplunkScript, add new step sendSplunkConsoleLog
- Loading branch information
Ted Xiao
committed
Nov 25, 2016
1 parent
6aa702c
commit c0a3888
Showing
8 changed files
with
123 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
splunk-devops-extend/src/main/java/com/splunk/splunkjenkins/SplunkConsoleLogStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.splunk.splunkjenkins; | ||
|
||
import hudson.Extension; | ||
import hudson.console.ConsoleLogFilter; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.workflow.steps.*; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class SplunkConsoleLogStep extends AbstractStepImpl { | ||
@DataBoundConstructor | ||
public SplunkConsoleLogStep() { | ||
} | ||
|
||
@Extension(optional = true) | ||
public static class DescriptorImpl extends AbstractStepDescriptorImpl { | ||
public DescriptorImpl() { | ||
super(ExecutionImpl.class); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getFunctionName() { | ||
return "sendSplunkConsoleLog"; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return "Send console log Splunk"; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean takesImplicitBlockArgument() { | ||
return true; | ||
} | ||
} | ||
|
||
|
||
public static class ExecutionImpl extends AbstractStepExecutionImpl { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean start() throws Exception { | ||
//refer to WithContextStep implementation | ||
StepContext context = getContext(); | ||
Run run = context.get(Run.class); | ||
ConsoleLogFilter filter = BodyInvoker.mergeConsoleLogFilters(context.get(ConsoleLogFilter.class), new TeeConsoleLogFilter(run)); | ||
context.newBodyInvoker().withContext(filter).withCallback(BodyExecutionCallback.wrap(context)).start(); | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void stop(@Nonnull Throwable cause) throws Exception { | ||
getContext().onFailure(cause); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...vops-extend/src/main/resources/com/splunk/splunkjenkins/SplunkConsoleLogStep/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
Forwarding pipeline console log to Splunk | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters