From bd02cfe4582b3b7a931bc4e836bc2b9c77e0fa20 Mon Sep 17 00:00:00 2001 From: Damian Szczepanik Date: Fri, 22 Feb 2019 23:01:48 +0100 Subject: [PATCH] Adds Codacy badge --- README.md | 28 +++++++++---------- .../jenkins/SafeArchiveServingAction.java | 7 +++-- .../jenkins/SafeArchiveServingRunAction.java | 7 ++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c3d1e0c..57221e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![Build Travis](https://img.shields.io/travis/jenkinsci/cucumber-reports-plugin/master.svg)](https://travis-ci.org/jenkinsci/cucumber-reports-plugin) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a9f4e032a47461fb984cd39c599584d)](https://www.codacy.com/app/damianszczepanik/cucumber-reports-plugin?utm_source=github.com&utm_medium=referral&utm_content=jenkinsci/cucumber-reports-plugin&utm_campaign=Badge_Grade) + # Publish pretty [cucumber](https://cucumber.io/) reports on [Jenkins](http://jenkins-ci.org/) This is a Java Jenkins plugin which publishes [pretty html reports](https://github.com/damianszczepanik/cucumber-reporting) showing the results of cucumber runs. To use with regular cucumber just make sure to run cucumber like this: cucumber `--plugin json -o cucumber.json` @@ -12,11 +14,9 @@ This plugin allows Jenkins to publish the results as pretty html reports hosted ## Install -1. [Get](https://jenkins-ci.org/) Jenkins. - -2. Install the [Cucumber Reports](https://wiki.jenkins-ci.org/display/JENKINS/Cucumber+Reports+Plugin) plugin. - -3. Restart Jenkins. + 1. [Get](https://jenkins-ci.org/) Jenkins. + 2. Install the [Cucumber Reports](https://wiki.jenkins-ci.org/display/JENKINS/Cucumber+Reports+Plugin) plugin. + 3. Restart Jenkins. Read this if you need further [detailed install and configuration](https://github.com/jenkinsci/cucumber-reports-plugin/wiki/Detailed-Configuration) instructions @@ -32,11 +32,11 @@ If you need more control over the plugin you can click the Advanced button for m ![](https://github.com/jenkinsci/cucumber-reports-plugin/raw/master/.README/advanced-publish-box.png) -1. Leave empty for the plugin to automagically find your json files or enter the path to the json reports relative to the workspace if for some reason the automagic doesn't work for you -2. Leave empty unless your jenkins is installed on a different url to the default hostname:port - see the wiki for further info on this option -3. Tick if you want Skipped steps to cause the build to fail - see further down for more info on this -4. Tick if you want Not Implemented/Pending steps to cause the build to fail - see further down for more info on this -5. Tick if you want failed test not to fail the entire build but make it unstable + 1. Leave empty for the plugin to automagically find your json files or enter the path to the json reports relative to the workspace if for some reason the automagic doesn't work for you + 2. Leave empty unless your jenkins is installed on a different url to the default hostname:port - see the wiki for further info on this option + 3. Tick if you want Skipped steps to cause the build to fail - see further down for more info on this + 4. Tick if you want Not Implemented/Pending steps to cause the build to fail - see further down for more info on this + 5. Tick if you want failed test not to fail the entire build but make it unstable ## Advanced Configuration Options @@ -48,17 +48,17 @@ The first setting is Skipped steps fail the build - so if you tick this any step If you check both skipped and not implemented fails the build then your report will look something like this: - Make sure you have configured cucumber to run with the JUnit runner and to generate a json report: (note - you can add other formatters in if you like e.g. pretty - but only the json formatter is required for the reports to work) - +```java import cucumber.junit.Cucumber; import org.junit.runner.RunWith; - + @RunWith(Cucumber.class) @Cucumber.Options(format = {"json:target/cucumber.json"}) public class MyTest { - + } +``` ## Automated configuration diff --git a/src/main/java/net/masterthought/jenkins/SafeArchiveServingAction.java b/src/main/java/net/masterthought/jenkins/SafeArchiveServingAction.java index 75168ab..3525a69 100644 --- a/src/main/java/net/masterthought/jenkins/SafeArchiveServingAction.java +++ b/src/main/java/net/masterthought/jenkins/SafeArchiveServingAction.java @@ -50,6 +50,8 @@ */ public class SafeArchiveServingAction implements Action { + private static final Logger LOGGER = Logger.getLogger(SafeArchiveServingAction.class.getName()); + private Map fileChecksums = new HashMap<>(); private final File rootDir; @@ -147,7 +149,8 @@ private void processDirectory(@Nonnull File directory, @Nullable String path) th * Record the checksums of files in the specified directory and its descendants unless a file type is whitelisted as * safe. * - * @throws NoSuchAlgorithmException If the platform does unexpectedly not support SHA-1 + * @throws NoSuchAlgorithmException when the platform does unexpectedly not support SHA-1 + * @throws IOException when the file or directory for specified file could not be created */ public void processDirectory() throws NoSuchAlgorithmException, IOException { LOGGER.log(Level.FINE, "Scanning " + getRootDir()); @@ -299,6 +302,4 @@ public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object nod } } } - - private static final Logger LOGGER = Logger.getLogger(SafeArchiveServingAction.class.getName()); } diff --git a/src/main/java/net/masterthought/jenkins/SafeArchiveServingRunAction.java b/src/main/java/net/masterthought/jenkins/SafeArchiveServingRunAction.java index da178cb..979341c 100644 --- a/src/main/java/net/masterthought/jenkins/SafeArchiveServingRunAction.java +++ b/src/main/java/net/masterthought/jenkins/SafeArchiveServingRunAction.java @@ -8,10 +8,9 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; - import hudson.model.Action; import hudson.model.Run; +import javax.annotation.Nonnull; import jenkins.model.RunAction2; import jenkins.tasks.SimpleBuildStep; @@ -21,6 +20,8 @@ */ public class SafeArchiveServingRunAction extends SafeArchiveServingAction implements RunAction2, SimpleBuildStep.LastBuildAction { + private static final Logger LOGGER = Logger.getLogger(SafeArchiveServingRunAction.class.getName()); + private Run run; public SafeArchiveServingRunAction(@Nonnull Run r, File rootDir, String urlName, String indexFile, String iconName, String title, String... safeExtensions) { @@ -47,6 +48,4 @@ public void onLoad(Run r) { public Collection getProjectActions() { return Collections.singleton(new CucumberReportProjectAction(run.getParent())); } - - private static final Logger LOGGER = Logger.getLogger(SafeArchiveServingRunAction.class.getName()); }