Fixed Issue #8 - added project level report link to the latest completed build and added cucmber icon for the image
This commit is contained in:
parent
ccf909f856
commit
9c5b0c4b17
|
@ -1,10 +1,12 @@
|
|||
package net.masterthought.jenkins;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.PluginWrapper;
|
||||
import hudson.model.AbstractItem;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.DirectoryBrowserSupport;
|
||||
import hudson.model.ProminentProjectAction;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
|
@ -23,7 +25,7 @@ public abstract class CucumberReportBaseAction implements Action {
|
|||
}
|
||||
|
||||
public String getIconFileName(){
|
||||
return dir().exists() ? "graph.gif" : null;
|
||||
return "/plugin/cucumber-reports/cuke.gif";
|
||||
}
|
||||
|
||||
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
|
|
|
@ -1,40 +1,52 @@
|
|||
//package net.masterthought.jenkins;
|
||||
//
|
||||
//import hudson.model.AbstractItem;
|
||||
//import hudson.model.AbstractProject;
|
||||
//import hudson.model.ProminentProjectAction;
|
||||
//import hudson.model.Run;
|
||||
//
|
||||
//import java.io.File;
|
||||
//
|
||||
//public class CucumberReportProjectAction extends CucumberReportBaseAction implements ProminentProjectAction {
|
||||
// private final AbstractItem project;
|
||||
//
|
||||
// public CucumberReportProjectAction(AbstractItem project) {
|
||||
// super();
|
||||
// this.project = project;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected File dir() {
|
||||
// if (this.project instanceof AbstractProject) {
|
||||
// AbstractProject abstractProject = (AbstractProject) this.project;
|
||||
//
|
||||
// Run run = abstractProject.getLastSuccessfulBuild();
|
||||
// if (run != null) {
|
||||
// File javadocDir = getBuildArchiveDir(run);
|
||||
//
|
||||
// if (javadocDir.exists()) {
|
||||
// return javadocDir;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return getProjectArchiveDir(this.project);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected String getTitle() {
|
||||
// return this.project.getDisplayName() + " html2";
|
||||
// }
|
||||
//}
|
||||
package net.masterthought.jenkins;
|
||||
|
||||
import hudson.model.AbstractItem;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.ProminentProjectAction;
|
||||
import hudson.model.Run;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CucumberReportProjectAction extends CucumberReportBaseAction implements ProminentProjectAction {
|
||||
private final AbstractItem project;
|
||||
|
||||
public CucumberReportProjectAction(AbstractItem project) {
|
||||
super();
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File dir() {
|
||||
if (this.project instanceof AbstractProject) {
|
||||
AbstractProject abstractProject = (AbstractProject) this.project;
|
||||
|
||||
Run run = abstractProject.getLastCompletedBuild();
|
||||
if (run != null) {
|
||||
File javadocDir = getBuildArchiveDir(run);
|
||||
|
||||
if (javadocDir.exists()) {
|
||||
return javadocDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getProjectArchiveDir(this.project);
|
||||
}
|
||||
|
||||
private File getProjectArchiveDir(AbstractItem project) {
|
||||
return new File(project.getRootDir(), "cucumber-html-reports");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory where the HTML report is stored for the given build.
|
||||
*/
|
||||
private File getBuildArchiveDir(Run run) {
|
||||
return new File(run.getRootDir(), "cucumber-html-reports");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return this.project.getDisplayName() + " html2";
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import hudson.FilePath;
|
|||
import hudson.Launcher;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.tasks.BuildStepDescriptor;
|
||||
import hudson.tasks.BuildStepMonitor;
|
||||
|
@ -98,6 +99,11 @@ public class CucumberReportPublisher extends Recorder {
|
|||
return fullPathList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getProjectAction(AbstractProject<?, ?> project) {
|
||||
return new CucumberReportProjectAction(project);
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
|
||||
@Override
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in New Issue