Skip to content

Commit

Permalink
Added symbol name for better pipeline integration (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke authored and centic9 committed Mar 25, 2017
1 parent 4baa40f commit a729cfa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ THE SOFTWARE.
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.2</version>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/hudson/plugins/jacoco/JacocoPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import java.util.Map;

import jenkins.MasterToSlaveFileCallable;
import jenkins.model.Jenkins;
import jenkins.tasks.SimpleBuildStep;
import org.apache.tools.ant.DirectoryScanner;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -727,15 +729,20 @@ public BuildStepMonitor getRequiredMonitorService() {

@Override
public BuildStepDescriptor<Publisher> getDescriptor() {
return DESCRIPTOR;
return (BuildStepDescriptor<Publisher>)super.getDescriptor();
}

@Extension
public static final BuildStepDescriptor<Publisher> DESCRIPTOR = new DescriptorImpl();
/**
* @deprecated
* use injection via {@link Jenkins#getInjector()}
*/
public static /*final*/ BuildStepDescriptor<Publisher> DESCRIPTOR;

@Extension @Symbol("jacoco")
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
public DescriptorImpl() {
super(JacocoPublisher.class);
DESCRIPTOR = this;
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/hudson/plugins/jacoco/JacocoPublisherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.*;
import hudson.plugins.jacoco.JacocoPublisher.DescriptorImpl;
import org.easymock.IAnswer;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -148,7 +149,7 @@ public void testGetterSetter() throws Exception {

assertEquals(BuildStepMonitor.NONE, publisher.getRequiredMonitorService());

BuildStepDescriptor<Publisher> descriptor = publisher.getDescriptor();
BuildStepDescriptor<Publisher> descriptor = new DescriptorImpl();
assertNotNull(descriptor);
assertNotNull(descriptor.getDisplayName());
assertTrue(descriptor.isApplicable(null));
Expand Down

0 comments on commit a729cfa

Please sign in to comment.