Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
967883a
External Logging API Plugin Skeleton
oleg-nenashev Jul 9, 2018
f581b7f
Elasticsearch/Logstash Reference implementation prototype
oleg-nenashev Jul 9, 2018
878ab4a
Add config Jelly for the external configuration
oleg-nenashev Jul 9, 2018
94fc946
Add smoke tests for ExternalLogging API
oleg-nenashev Jul 9, 2018
509d67e
Add a Demo draft
oleg-nenashev Jul 9, 2018
0d92ffd
Add support of debugging Jenkins from the demo + self-configuration o…
oleg-nenashev Jul 9, 2018
56759dc
Route Pipeline logs through the ExternalLogBrowser implementation, Lo…
oleg-nenashev Jul 9, 2018
a650819
Implement new API from the Jenkins Core
oleg-nenashev Jul 16, 2018
4915012
Add “disabled” implementations for Log Browser and Logging Method
oleg-nenashev Jul 16, 2018
5712faf
Use the latest PluginPOM
oleg-nenashev Jul 16, 2018
7c704d7
Fix tests for Jenkins Pipeline
oleg-nenashev Jul 16, 2018
9c9b87b
Add integration tests for the External Logging for Elasticsearch Plugin
oleg-nenashev Jul 16, 2018
549d9fa
Elasticsearch test container now can wait till ES fully starts up
oleg-nenashev Jul 18, 2018
cbd7307
Updates towards the new version of External Logging API and Logstash …
oleg-nenashev Jul 23, 2018
a5c694f
Move External Logging for Logstash to a separate plugin
oleg-nenashev Jul 23, 2018
fdba32b
Move Launcher decoration logic from the core to External Logging API …
oleg-nenashev Jul 23, 2018
64adfc7
Update API to reflect the recent patches in Jenkins Core upstream
oleg-nenashev Jul 23, 2018
e1a8da4
It is no longer required to decorate loggers in the implementations
oleg-nenashev Jul 23, 2018
a720913
createWriter() now injects standard metadata to all writers
oleg-nenashev Jul 23, 2018
82515e7
Document ExternalLoggingMethod#createWriter() methods
oleg-nenashev Jul 23, 2018
5fc2c54
Some API relocations and documentation patches
oleg-nenashev Jul 24, 2018
bf72e10
External Logging Method calls now propagate errors in API
oleg-nenashev Jul 24, 2018
32dc947
Pick Jenkins core release from Incrementals
oleg-nenashev Jul 31, 2018
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
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
target

# mvn hpi:run
work

# IntelliJ IDEA project files
*.iml
*.iws
*.ipr
.idea

# Eclipse project files
.settings
.classpath
.project
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.0-beta-3</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildPlugin(platforms: ['linux'])
126 changes: 126 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

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

<groupId>io.jenkins.plugins.external-logging</groupId>
<artifactId>external-logging-api</artifactId>
<name>External Logging API plugin</name>
<description>The plugin provides API to simplify external logging implementations for Jenkins</description>
<url>https://wiki.jenkins.io/display/JENKINS/External+Logging+API+Plugin</url>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>

<properties>
<revision>1.0-alpha-1</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.135-rc15088.42aa6febbbed</jenkins.version>
<java.level>8</java.level>
<useBeta>true</useBeta>
</properties>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>${scmTag}</tag>
</scm>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>unique-id</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mask-passwords</artifactId>
<version>2.12.0</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.22-rc311.5616213fbed0</version> <!-- TODO https://github.com/jenkinsci/workflow-job-plugin/pull/27 -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.19-rc265.3e5e4aeecfff</version> <!-- TODO https://github.com/jenkinsci/workflow-support-plugin/pull/15 -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.29-rc219.239019e84015</version> <!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/17 -->
</dependency>

<!-- For testing of Log wrapping in Pipeline -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.20-rc333.74dc7c303e6d</version> <!-- TODO https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/21 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.15</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.39</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials-binding</artifactId>
<version>1.15</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

</project>
54 changes: 54 additions & 0 deletions src/main/java/io/jenkins/plugins/extlogging/api/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.jenkins.plugins.extlogging.api;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
* Stores events which can be sent over the channel.
* @author Oleg Nenashev
* @since TODO
*/
public class Event {

final String message;
final long timestamp;
final long id;

Map<String, Serializable> data = new HashMap<>();

public Event(long id, String message, long timestamp) {
this.id = id;
this.message = message;
this.timestamp = timestamp;
}

public long getId() {
return id;
}

public String getMessage() {
return message;
}

public long getTimestamp() {
return timestamp;
}

public Map<String, Serializable> getData() {
return data;
}

@Override
public String toString() {
return String.format("[%d] - %s", timestamp, message);
}

public void setData(Map<String, Serializable> data) {
this.data = data;
}

public String toStringWithData() {
return String.format("[%d] - %s: %s", timestamp, message, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.jenkins.plugins.extlogging.api;

import jenkins.model.logging.LogBrowser;
import jenkins.model.logging.Loggable;

import javax.annotation.Nonnull;

/**
* Base abstract class for External Log Browsers.
* @author Oleg Nenashev
* @since TODO
*/
public abstract class ExternalLogBrowser extends LogBrowser {

public ExternalLogBrowser(@Nonnull Loggable loggable) {
super(loggable);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.jenkins.plugins.extlogging.api;

import hudson.ExtensionPoint;
import hudson.model.Describable;
import hudson.model.Descriptor;
import jenkins.model.Jenkins;
import jenkins.model.logging.LogBrowser;
import jenkins.model.logging.Loggable;

import javax.annotation.CheckForNull;

/**
* @author Oleg Nenashev
* @since TODO
*/
public abstract class ExternalLogBrowserFactory
implements Describable<ExternalLogBrowserFactory>, ExtensionPoint {

@CheckForNull
public abstract LogBrowser create(Loggable loggable);

@Override
public Descriptor<ExternalLogBrowserFactory> getDescriptor() {
return Jenkins.get().getDescriptor(getClass());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.jenkins.plugins.extlogging.api;

import hudson.model.Descriptor;

/**
* Descriptor for {@link ExternalLogBrowserFactory}
* @author Oleg Nenashev
* @since TODO
*/
public class ExternalLogBrowserFactoryDescriptor
extends Descriptor<ExternalLogBrowserFactory> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.jenkins.plugins.extlogging.api;

import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

/**
* Implements logging of events
* @author Oleg Nenashev
* @since TODO
*/
public abstract class ExternalLoggingEventWriter extends Writer implements Serializable {

Map<String, Serializable> metadata = new HashMap<>();
AtomicLong messageCounter = new AtomicLong();

public abstract void writeEvent(Event event) throws IOException;

public void writeMessage(String message) throws IOException {
Event event = new Event(messageCounter.getAndIncrement(), message, System.currentTimeMillis());
event.setData(metadata); // We do not copy the entry to save performance, custom implementations may need better logic
writeEvent(event);
}

public void addMetadataEntry(String key, Serializable value) {
metadata.put(key, value);
}

@Override
public void write(char[] cbuf, int off, int len) throws IOException {
String message = new String(cbuf, off, len);
writeMessage(message);
}

@Override
public void close() throws IOException {
// noop
}

@Override
public void flush() throws IOException {
// noop
}
}
Loading