Skip to content

Commit

Permalink
second wild dump
Browse files Browse the repository at this point in the history
  • Loading branch information
akostadinov committed Aug 8, 2018
1 parent a34d055 commit 75d7aa8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public OutputStream decorateLogger(Run build, OutputStream logger) throws IOExce
{
if (isLogstashEnabled(build))
{
LogstashWriter logstash = getLogStashWriter(build, logger, null);
LogstashWriter logstash = getLogStashWriter(build, logger, secureGroovyScript);
return new LogstashOutputStream(logger, logstash);
}
else
Expand Down Expand Up @@ -93,8 +93,10 @@ private boolean isLogstashEnabled(Run<?, ?> build)
if (build.getParent() instanceof AbstractProject)
{
AbstractProject<?, ?> project = (AbstractProject<?, ?>)build.getParent();
if (project.getProperty(LogstashJobProperty.class) != null)
LogstashJobProperty jobProperty = project.getProperty(LogstashJobProperty.class);
if (jobProperty != null)
{
this.secureGroovyScript = jobProperty.getSecureGroovyScript();
return true;
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/jenkins/plugins/logstash/LogstashJobProperty.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package jenkins.plugins.logstash;

import javax.annotation.CheckForNull;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;

import hudson.Extension;
Expand All @@ -9,18 +12,32 @@
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import net.sf.json.JSONObject;
import org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript;

/**
* This JobProperty is a marker to decide if logs should be sent to an indexer.
*
*/
public class LogstashJobProperty extends JobProperty<Job<?, ?>>
{
@CheckForNull
private SecureGroovyScript secureGroovyScript = null;

@DataBoundConstructor
public LogstashJobProperty()
{}

@DataBoundSetter
public void setSecureGroovyScript(@CheckForNull SecureGroovyScript script)
{
this.secureGroovyScript = script != null ? script.configuringWithNonKeyItem() : null;
}

public SecureGroovyScript getSecureGroovyScript()
{
return this.secureGroovyScript;
}

@Extension
public static class DescriptorImpl extends JobPropertyDescriptor
{
Expand Down

0 comments on commit 75d7aa8

Please sign in to comment.