Skip to content

Commit

Permalink
Refactor plugin to support latest Jenkins and Sentry version
Browse files Browse the repository at this point in the history
Sentry SDK was updated to the latest one together with cleaning up unused code.
Logger handler now is a dedicated dependency that should be listed.

More in the [doc][1].

Jenkins BOM is taken from [article][2]

[1]: https://docs.sentry.io/platforms/java/guides/jul/
[2]: https://www.jenkins.io/doc/developer/plugin-development/dependency-management/
  • Loading branch information
kuzaxak committed Oct 3, 2023
1 parent a29347c commit cf0759d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 64 deletions.
37 changes: 9 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.2</version>
<version>4.74</version>
</parent>


<groupId>io.jenkins.plugins</groupId>
<artifactId>sentry</artifactId>
<version>1.5.0</version>
<version>6.30.0</version>
<packaging>hpi</packaging>
<description>Integrates Jenkins with the Sentry error reporting service</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Sentry+Plugin</url>
Expand All @@ -64,7 +64,12 @@
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.5.0</version>
<version>6.30.0</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-jul</artifactId>
<version>6.30.0</version>
</dependency>
</dependencies>

Expand All @@ -83,30 +88,6 @@
</pluginRepositories>

<properties>
<jenkins.version>2.60.3</jenkins.version>
<java.level>7</java.level>
<jenkins.version>2.401.3</jenkins.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<configuration>
<providerSelection>1.8</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

This file was deleted.

This file was deleted.

11 changes: 2 additions & 9 deletions src/main/groovy/io/jenkins/plugins/sentry/SentryPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ class SentryPlugin extends Plugin {

Sentry.init()

System.env.each { key, value ->
key.eachMatch('SENTRY_TAG_(\\w+)') { match ->
LOG.info("Adding a tag for `${match[1]}` with `${value}`")
Sentry.context.addTag(match[1], value)
}
}

if (!System.env.get('SENTRY_NO_LOGWATCHER')) {
addLogWatcher()
}
Expand All @@ -45,15 +38,15 @@ class SentryPlugin extends Plugin {
Logger manager = LogManager.logManager.getLogger(loggerName)

boolean found = false
manager?.handlers?.toList().each { handler ->
manager?.handlers?.toList()?.each { handler ->
if (handler.class == SentryHandler) {
found = true
}
}

if (!found) {
LOG.info("Adding Sentry to ${loggerName}")
manager?.addHandler(sentry)
manager?.addHandler(sentry as Handler)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
Integrates Jenkins with the Sentry error reporting service
</div>

0 comments on commit cf0759d

Please sign in to comment.