Package hudson.plugins.rubyMetrics.saikuro

Source Code of hudson.plugins.rubyMetrics.saikuro.SaikuroPublisher$SaikuroFilenameFilter

package hudson.plugins.rubyMetrics.saikuro;

import hudson.Launcher;
import hudson.model.*;
import hudson.plugins.rubyMetrics.HtmlPublisher;
import hudson.plugins.rubyMetrics.saikuro.model.SaikuroResult;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

public class SaikuroPublisher extends HtmlPublisher {

    @DataBoundConstructor
    public SaikuroPublisher(String reportDir) {
        this.reportDir = reportDir;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
        final SaikuroFilenameFilter indexFilter = new SaikuroFilenameFilter();
        prepareMetricsReportBeforeParse(build, listener, indexFilter, DESCRIPTOR.getToolShortName());
        if (build.getResult() == Result.FAILURE) {
            return false;
        }

        SaikuroParser parser = new SaikuroParser(build.getRootDir(), listener);
        SaikuroResult results = parser.parse(getCoverageFiles(build, indexFilter)[0]);

        SaikuroBuildAction action = new SaikuroBuildAction(build, results);
        build.getActions().add(action);

        return true;
    }

    private static class SaikuroFilenameFilter implements FilenameFilter {
        public boolean accept(File dir, String name) {
            return name.equalsIgnoreCase("index_cyclo.html");
        }
    }

    @Override
    public Action getProjectAction(final AbstractProject<?, ?> project) {
        return new SaikuroProjectAction(project);
    }

    //@Extension
    public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

    public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {

        protected DescriptorImpl() {
            super(SaikuroPublisher.class);
        }

        public String getToolShortName() {
            return "saikuro";
        }

        @Override
        public String getDisplayName() {
            return "Publish Saikuro report";
        }

        @Override
        public boolean isApplicable(Class<? extends AbstractProject> jobType) {
            return true;
        }

        @Override
        public SaikuroPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
            return req.bindParameters(SaikuroPublisher.class, "saikuro.");
        }
    }

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

}
TOP

Related Classes of hudson.plugins.rubyMetrics.saikuro.SaikuroPublisher$SaikuroFilenameFilter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.
es.plugins.credentials.common.StandardListBoxModel">com.cloudbees.plugins.credentials.common.StandardListBoxModel
  • com.cloudbees.plugins.credentials.domains.SchemeRequirement
  • com.cloudbees.plugins.credentials.impl.CertificateCredentialsImpl
  • com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl
  • com.sonyericsson.hudson.plugins.gerrit.trigger.config.ReplicationConfig
  • com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer
  • TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.