Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-54128] fix deprecated call to run.getLogFile #7

Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http://wiki.jenkins-ci.org/display/JENKINS/LineNumber
https://plugins.jenkins.io/linenumbers
18 changes: 11 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.32</version>
<version>4.24</version>
</parent>

<artifactId>linenumbers</artifactId>
<version>1.3-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Line Numbers plugin</name>
<description>This decorates the console with line numbers</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Line+Numbers+Plugin</url>

<url>https://plugins.jenkins.io/linenumbers</url>

<properties>
<java.level>8</java.level>
</properties>

<developers>
<developer>
<id>vlatombe</id>
<name>Vincent Latombe</name>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<tag>HEAD</tag>
</scm>

<licenses>
<license>
<name>The MIT license</name>
Expand All @@ -49,7 +53,7 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<distributionManagement>
<repository>
<id>repo.jenkins-ci.org</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/*
* The MIT License
*
* Copyright (c) 20import hudson.MarkupText;
import hudson.console.ConsoleAnnotator;
import hudson.model.Run;

import java.text.MessageFormat;
d associated documentation files (the "Software"), to deal
*
* Copyright (c) 2014, Vincent Latombe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -31,7 +29,7 @@ d associated documentation files (the "Software"), to deal

import java.text.MessageFormat;

public class LineNumbersAnnotator extends ConsoleAnnotator<Object> {
public class LineNumbersAnnotator extends ConsoleAnnotator<Run<?, ?>> {

private int calls = 0;

Expand All @@ -44,14 +42,11 @@ public LineNumbersAnnotator(long offset) {
}

@Override
public ConsoleAnnotator annotate(Object context, MarkupText text) {
if (!(context instanceof Run)) {
return this;
}
Run r = (Run)context;
long start;
public ConsoleAnnotator<Run<?, ?>> annotate(Run<?, ?> r, MarkupText text) {

final long start;
if (offset < 0) {
start = r.getLogFile().length() + offset;
start = r.getLogText().length() + offset;
} else {
start = offset;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2014, Vincent Latombe
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -26,20 +26,21 @@
import hudson.Extension;
import hudson.console.ConsoleAnnotator;
import hudson.console.ConsoleAnnotatorFactory;
import hudson.model.Run;

import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;

/**
* Adds line numbers to the console logs as well as bookmarkable anchors
*
*
* @author vlatombe
*
*
*/
@Extension(ordinal = -100)
public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory<Object> {
public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory<Run<?, ?>> {
@Override
public ConsoleAnnotator<Object> newInstance(Object context) {
public ConsoleAnnotator<Run<?, ?>> newInstance(Run<?, ?> context) {
long offset = getOffset(Stapler.getCurrentRequest());
return new LineNumbersAnnotator(offset);
}
Expand All @@ -49,7 +50,7 @@ public ConsoleAnnotator<Object> newInstance(Object context) {
* is from the start of the file, and a negative offset is back from the end
* of the file.
* Note : Copied from hudson.plugins.timestamper.annotator.TimestampAnnotatorFactory
*
*
* @param request
* @return the offset in bytes
*/
Expand Down