Skip to content

Commit

Permalink
Merge pull request #9 from alecharp/feature/refresh-plugin-configuration
Browse files Browse the repository at this point in the history
Refresh plugin configuration
  • Loading branch information
alecharp authored Nov 3, 2022
2 parents cefb917 + 1090dc6 commit 8569b05
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 56 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: .github
18 changes: 18 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Drafter

on:
push:
branches:
- main

# Only allow 1 release-drafter build at a time to avoid creating multiple "next" releases
concurrency: "release-drafter"

jobs:
update_release_draft:
runs-on: ubuntu-22.04
steps:
- uses: release-drafter/release-drafter@v5.21.1
env:
# This token is generated automatically by default in GitHub Actions: no need to create it manually
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.4</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Change Log

Starting with release 0.9.0, release notes can be found on [GitHub Releases page](https://github.com/jenkinsci/cucumber-slack-notifier-plugin/releases)

### Version 0.8.3 (19th July 2016)

- Adds option to report only failures ([#2](https://github.com/jenkinsci/cucumber-slack-notifier-plugin/pull/2))

### Version 0.8.2 (4th July 2016)

- Added ability to add custom text a message

### Version 0.8.1 (4th July 2016)

- Fixed issue with link generation in slack message

### Version 0.8 (3th July 2016)

- Added Jenkins Pipeline Support

### Version 0.7 (17th Dec 2015)

- Added Build Step & Post Build Notifiers
- Added Global Config Validation
- Implemented common service for sending notifications

### Version 0.6.1 (17th Dec 2015)

- Fixed invalid check for configuration

### Version 0.6 (16th Dec 2015)

- Correctly reading json report file from the workspace directory

### Version 0.4 (15th Dec 2015)

- Initial Release
5 changes: 5 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
buildPlugin(configurations: [
[ platform: 'linux', jdk: '11' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# cucumber-slack-notifier-plugin
# Cucumber Slack Notifier plugin
Jenkins plugin to push summarised Cucumber reports to Slack

[![Build Status](https://travis-ci.org/garethjevans/cucumber-slack-notifier-plugin.svg)](https://travis-ci.org/garethjevans/cucumber-slack-notifier-plugin)
## Jenkins Pipeline Usage

## Installation
Use within a node block as the example below shows:

Coming Soon...
``` syntaxhighlighter-pre
node {
stage 'Cucumber Reports'
// process cucumber reports
step([$class: 'CucumberReportPublisher', jsonReportDirectory: 'target/', fileIncludePattern: '*.json'])
## Configuration
// send report to slack
cucumberSendSlack: channel: 'test-results-channel', json: 'target/test-results.json'
}
```

The following options are available:
## Installation Instructions

### Global Configuration

* webHookEndpoint
![](docs/images/global_config.png)

TODO: add a screen shot here
### Job Configuration

* Channel Webhook URL - slack channel Webhook URL to post result to
* JSON Result File - json file containing the cucumber results, e.g. target/cucumber.json

![config](https://i.ibb.co/sj6X6T8/Screenshot-from-2019-04-23-14-46-47.png)
![](docs/images/job_config.png)
Binary file added docs/images/global_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/job_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 37 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.13</version>
<relativePath />
<version>4.49</version>
<relativePath/>
</parent>

<artifactId>cucumber-slack-notifier</artifactId>
<version>0.9.0</version>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Cucumber+Slack+Notifier+Plugin</url>
<url>https://github.com/${gitHubRepo}</url>

<properties>
<revision>0.10.0</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/cucumber-slack-notifier-plugin</gitHubRepo>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<workflow.version>2.13</workflow.version>
<jenkins.version>2.346.3</jenkins.version>
</properties>

<developers>
Expand All @@ -29,71 +32,81 @@
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.346.x</artifactId>
<version>1670.v7f165fc7a_079</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-httpclient3-api</artifactId>
<version>3.1-3</version>
</dependency>
<!-- for workflow support -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency> <!-- StepConfigTester -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<classifier>tests</classifier>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<scm>
<connection>scm:git:ssh://github.com/jenkinsci/cucumber-slack-notifier-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/cucumber-slack-notifier-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/cucumber-slack-notifier-plugin</url>
<tag>cucumber-slack-notifier-0.9.0</tag>
<connection>scm:git:ssh://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
Expand All @@ -102,16 +115,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
<configuration>
<failOnError>false</failOnError>
<threshold>Low</threshold>
</configuration>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.slacknotifier;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
Expand Down Expand Up @@ -55,9 +56,12 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
}

CucumberSlackService service = new CucumberSlackService(webhookUrl);
service.sendCucumberReportToSlack(build, build.getWorkspace(), json, channel, null, hideSuccessfulResults);

return true;
final FilePath workspace = build.getWorkspace();
if (workspace != null) {
service.sendCucumberReportToSlack(build, workspace, json, channel, null, hideSuccessfulResults);
return true;
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.slacknotifier;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
Expand Down Expand Up @@ -61,9 +62,12 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
LOG.info("hideSuccessfulResults = ***" + hideSuccessfulResults + "***");

CucumberSlackService service = new CucumberSlackService(webhookUrl);
service.sendCucumberReportToSlack(build, build.getWorkspace(), json, channel, null, hideSuccessfulResults);

return true;
final FilePath workspace = build.getWorkspace();
if (workspace != null) {
service.sendCucumberReportToSlack(build, workspace, json, channel, null, hideSuccessfulResults);
return true;
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;

public class CucumberSlackService {
Expand All @@ -35,7 +36,7 @@ private JsonElement getResultFileAsJsonElement(FilePath workspace, String json)

final Gson gson = new Gson();
try {
final JsonReader jsonReader = new JsonReader(new InputStreamReader(jsonPath.read()));
final JsonReader jsonReader = new JsonReader(new InputStreamReader(jsonPath.read(), StandardCharsets.UTF_8));
return gson.fromJson(jsonReader, JsonElement.class);
} catch (IOException | InterruptedException e) {
LOG.severe("Exception occurred while reading test results: " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public CucumberResult processResults(JsonElement resultElement) {
}
}
totalScenarios = totalScenarios + scenariosTotal;
final int scenarioPassPercent = Math.round(((scenariosTotal - failed) * 100) / scenariosTotal);
final int scenarioPassPercent = ((scenariosTotal - failed) * 100) / scenariosTotal;
if (scenarioPassPercent != 100 || !hideSuccessfulResults) {
results.add(new FeatureResult(feature.get("uri").getAsString(), feature.get("name").getAsString(), scenarioPassPercent));
}
}
passPercent = Math.round(((totalScenarios - failedScenarios) * 100) / totalScenarios);
passPercent = ((totalScenarios - failedScenarios) * 100) / totalScenarios;
return new CucumberResult(results, totalScenarios, passPercent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean getHideSuccessfulResults() {

@DataBoundSetter
public void setHideSuccessfulResults(String hideSuccessfulResults) {
this.hideSuccessfulResults = Boolean.getBoolean(Util.fixEmpty(hideSuccessfulResults));
this.hideSuccessfulResults = Boolean.getBoolean(hideSuccessfulResults);
}

public String getExtra() {
Expand Down

0 comments on commit 8569b05

Please sign in to comment.