Skip to content
Closed
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
56 changes: 9 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skipIntegrationTests>true</skipIntegrationTests>
<jenkins-test-harness.version>2.23</jenkins-test-harness.version>
<java.level>8</java.level>
<jenkins.version>2.60.3</jenkins.version>
<jenkins-credentials.version>2.1.11</jenkins-credentials.version>
</properties>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.15</version>
</parent>

<properties>
<java.level>8</java.level>
<jenkins.version>2.60.3</jenkins.version>
</properties>

<repositories>
<repository>
Expand All @@ -38,19 +33,6 @@
<tag>HEAD</tag>
</scm>

<distributionManagement>
<repository>
<id>maven.jenkins-ci.org</id>
<name>jenkinsci-releases</name>
<url>https://repo.jenkins-ci.org/releases</url>
</repository>
<snapshotRepository>
<id>maven.jenkins-ci.org</id>
<name>jenkinsci-snapshots</name>
<url>https://repo.jenkins-ci.org/snapshots</url>
</snapshotRepository>
</distributionManagement>

<artifactId>logstash</artifactId>
<packaging>hpi</packaging>
<version>2.1.1-SNAPSHOT</version>
Expand All @@ -60,9 +42,9 @@

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
<version>4.5.3-2.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -137,7 +119,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>${jenkins-credentials.version}</version>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
Expand Down Expand Up @@ -235,15 +217,6 @@
</dependencies>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<!-- http://jira.codehaus.org/browse/MRELEASE-812 -->
<plugin>
<artifactId>maven-release-plugin</artifactId>
Expand All @@ -260,17 +233,6 @@
</dependency>
</dependencies>
</plugin>

<!-- https://issues.jenkins-ci.org/browse/JENKINS-21977 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>InjectedTest.java</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
32 changes: 17 additions & 15 deletions src/main/java/jenkins/plugins/logstash/LogstashConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ public List<?> getIndexerTypes()

@SuppressWarnings("deprecation")
@Initializer(after = InitMilestone.JOB_LOADED)
public void migrateData()
public static void migrateData()

Choose a reason for hiding this comment

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

actually what is the reason for making this method static?

Copy link
Member Author

Choose a reason for hiding this comment

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

The initializers are always static. The code won't even compile in newer versions otherwise IIRC

{
if (!dataMigrated)
LogstashConfiguration c = LogstashConfiguration.getInstance();
if (!c.dataMigrated)
{
Descriptor descriptor = LogstashInstallation.getLogstashDescriptor();
if (descriptor.getType() != null)
Expand All @@ -165,8 +166,8 @@ public void migrateData()
redis.setPort(descriptor.getPort());
redis.setKey(descriptor.getKey());
redis.setPassword(descriptor.getPassword());
logstashIndexer = redis;
enabled = true;
c.logstashIndexer = redis;
c.enabled = true;
break;
case ELASTICSEARCH:
LOGGER.log(Level.INFO, "Migrating logstash configuration for Elastic Search");
Expand All @@ -180,8 +181,8 @@ public void migrateData()
es.setUri(uri);
es.setUsername(descriptor.getUsername());
es.setPassword(descriptor.getPassword());
logstashIndexer = es;
enabled = true;
c.logstashIndexer = es;
c.enabled = true;
}
catch (URISyntaxException e)
{
Expand All @@ -197,8 +198,8 @@ public void migrateData()
rabbitMq.setQueue(descriptor.getKey());
rabbitMq.setUsername(descriptor.getUsername());
rabbitMq.setPassword(descriptor.getPassword());
logstashIndexer = rabbitMq;
enabled = true;
c.logstashIndexer = rabbitMq;
c.enabled = true;
break;
case SYSLOG:
LOGGER.log(Level.INFO, "Migrating logstash configuration for SYSLOG");
Expand All @@ -218,19 +219,20 @@ public void migrateData()
syslog.setMessageFormat(MessageFormat.RFC_3164);
break;
}
logstashIndexer = syslog;
enabled = true;
c.logstashIndexer = syslog;
c.enabled = true;
break;
default:
LOGGER.log(Level.INFO, "unknown logstash Indexer type: " + type);
enabled = false;
c.enabled = false;
break;
}
milliSecondTimestamps = false;
activeIndexer = logstashIndexer;
c.activeIndexer = c.logstashIndexer;
c.milliSecondTimestamps = false;
c.activeIndexer = logstashIndexer;
}
dataMigrated = true;
save();
c.dataMigrated = true;
c.save();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
Adds the possibility to push builds logs and build data to a Logstash indexer such as Redis, RabbitMQ, Elastic Search or to Syslog.
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<!-- We need to keep this file in order to prevent that in the UI we get the option to configure a Logstash Installation -->
<f:section title="Logstash Plugin" name="logstash">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:block>
<f:entry title="${%Max lines}" field="maxLines">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.concurrent.TimeUnit;
import net.sf.json.JSONObject;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.awaitility.Awaitility.*;
Expand All @@ -36,6 +37,7 @@ public void before() throws Exception {

// Send a real Syslog message to Logstash.
@Test
@Ignore
public void syslogSendRFC3164UDP() throws Exception {

PrintWriter writer = null;
Expand Down