diff --git a/install-fast b/install-fast
deleted file mode 100755
index dd50baa..0000000
--- a/install-fast
+++ /dev/null
@@ -1 +0,0 @@
-mvn -Dmaven.test.skip=true -DskipTests=true clean install
diff --git a/pom.xml b/pom.xml
index b1e8de2..643fb5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,126 +1,128 @@
+
- 4.0.0
-
- org.jenkins-ci.plugins
- plugin
- 4.82
-
-
- Badge
+ 4.0.0
+
org.jenkins-ci.plugins
- badge
- ${revision}${changelist}
- hpi
- https://github.com/jenkinsci/badge-plugin
-
-
-
- strangelookingnerd
- Daniel Krämer
-
-
- bakito
- Marc Brugger
-
-
- wolfs
- Stefan Wolf
-
-
- beryx
- Serban Iordache
-
-
+ plugin
+ 4.82
+
+ org.jenkins-ci.plugins
+ badge
+ ${revision}${changelist}
+ hpi
-
-
- The MIT license
- https://opensource.org/licenses/mit-license.php
- repo
-
-
+ Badge
+ https://github.com/jenkinsci/badge-plugin
-
- 2.426.3
- 1.11
- -SNAPSHOT
- jenkinsci/badge-plugin
- Max
- Low
-
+
+
+ The MIT license
+ https://opensource.org/licenses/mit-license.php
+ repo
+
+
-
- scm:git:https://github.com/${gitHubRepo}.git
- scm:git:git@github.com:${gitHubRepo}.git
- https://github.com/${gitHubRepo}
- ${scmTag}
-
+
+
+ strangelookingnerd
+ Daniel Krämer
+
+
+ bakito
+ Marc Brugger
+
+
+ wolfs
+ Stefan Wolf
+
+
+ beryx
+ Serban Iordache
+
+
-
-
- repo.jenkins-ci.org
- https://repo.jenkins-ci.org/public/
-
-
+
+ scm:git:https://github.com/${gitHubRepo}.git
+ scm:git:git@github.com:${gitHubRepo}.git
+ ${scmTag}
+ https://github.com/${gitHubRepo}
+
-
-
- repo.jenkins-ci.org
- https://repo.jenkins-ci.org/public/
-
-
-
-
-
- io.jenkins.tools.bom
- bom-2.426.x
- 3041.ve87ce2cdf223
- import
- pom
-
-
-
+
+ 2.426.3
+ 1.11
+ -SNAPSHOT
+ jenkinsci/badge-plugin
+ Max
+ Low
+ false
+
+
-
- org.jenkins-ci.plugins.workflow
- workflow-step-api
-
-
- org.jenkins-ci.plugins
- structs
-
-
- org.jenkins-ci.plugins
- script-security
-
-
- org.jenkins-ci.plugins
- antisamy-markup-formatter
-
-
- io.jenkins.plugins
- ionicons-api
-
-
- org.jenkins-ci.plugins.workflow
- workflow-cps
- test
-
-
- org.jenkins-ci.plugins.workflow
- workflow-step-api
- tests
- test
-
-
- org.jenkins-ci.plugins.workflow
- workflow-durable-task-step
- test
-
-
- org.jenkins-ci.plugins.workflow
- workflow-job
- test
-
+
+ io.jenkins.tools.bom
+ bom-2.426.x
+ 3041.ve87ce2cdf223
+ pom
+ import
+
+
+
+
+ io.jenkins.plugins
+ ionicons-api
+
+
+ org.jenkins-ci.plugins
+ antisamy-markup-formatter
+
+
+ org.jenkins-ci.plugins
+ script-security
+
+
+ org.jenkins-ci.plugins
+ structs
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-step-api
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-cps
+ test
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-durable-task-step
+ test
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-job
+ test
+
+
+ org.jenkins-ci.plugins.workflow
+ workflow-step-api
+ tests
+ test
+
+
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
+
+
+
+ repo.jenkins-ci.org
+ https://repo.jenkins-ci.org/public/
+
+
diff --git a/run-fast b/run-fast
deleted file mode 100755
index 4a22fcb..0000000
--- a/run-fast
+++ /dev/null
@@ -1,2 +0,0 @@
-rm -rf work/plugins
-mvn -Dmaven.test.skip=true -DskipTests=true clean hpi:run
diff --git a/src/main/java/com/jenkinsci/plugins/badge/BadgePlugin.java b/src/main/java/com/jenkinsci/plugins/badge/BadgePlugin.java
index 0bbe424..50c77c6 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/BadgePlugin.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/BadgePlugin.java
@@ -1,146 +1,148 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import hudson.Extension;
-import hudson.markup.RawHtmlMarkupFormatter;
-import hudson.model.Action;
-import hudson.model.Job;
-import hudson.model.Run;
-import jenkins.model.GlobalConfiguration;
-import org.kohsuke.stapler.DataBoundSetter;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
-import org.kohsuke.stapler.interceptor.RequirePOST;
-
-import java.io.IOException;
-import java.util.List;
-
-@Extension
-public class BadgePlugin extends GlobalConfiguration {
-
- /**
- * @return the singleton instance
- */
- public static BadgePlugin get() {
- return GlobalConfiguration.all().get(BadgePlugin.class);
- }
-
- private boolean disableFormatHTML;
-
- private final RawHtmlMarkupFormatter formatter = new RawHtmlMarkupFormatter(false);
-
- @SuppressFBWarnings(value="MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
- justification="Common pattern in Jenkins constructors")
- public BadgePlugin() {
- // When Jenkins is restarted, load any saved configuration from disk.
- load();
- }
-
- /**
- * @return the whether HTML formatting is disabled or not
- */
- public boolean isDisableFormatHTML() {
- return disableFormatHTML;
- }
-
- /**
- * Together with {@link #isDisableFormatHTML}, binds to entry in {@code config.jelly}.
- *
- * @param disableFormatHTML the new value of this field
- */
- @DataBoundSetter
- public void setDisableFormatHTML(boolean disableFormatHTML) {
- this.disableFormatHTML = disableFormatHTML;
- save();
- }
-
- @RequirePOST
- public void doRemoveBadges(StaplerRequest req, StaplerResponse rsp) throws IOException {
- removeActions(BadgeAction.class, req, rsp);
- }
-
- @RequirePOST
- public void doRemoveSummaries(StaplerRequest req, StaplerResponse rsp) throws IOException {
- removeActions(BadgeSummaryAction.class, req, rsp);
- }
-
- @SuppressWarnings("unchecked")
- private void removeActions(Class type, StaplerRequest req, StaplerResponse rsp) throws IOException {
- req.findAncestorObject(Job.class).checkPermission(Run.UPDATE);
- Run, ?> run = req.findAncestorObject(Run.class);
- if (run != null) {
- List extends Action> actions = run.getAllActions();
- List groovyActions = run.getActions(type);
- for (Action action : groovyActions) {
- actions.remove(action);
- }
- run.save();
- rsp.sendRedirect(req.getRequestURI().substring(0, req.getRequestURI().indexOf("parent/parent")));
- }
- }
-
- @RequirePOST
- public void doRemoveBadge(StaplerRequest req, StaplerResponse rsp) throws IOException {
- removeAction(BadgeAction.class, req, rsp);
- }
-
- @RequirePOST
- public void doRemoveSummary(StaplerRequest req, StaplerResponse rsp) throws IOException {
- removeAction(BadgeSummaryAction.class, req, rsp);
- }
-
- @SuppressWarnings("unchecked")
- private void removeAction(Class type, StaplerRequest req, StaplerResponse rsp) throws IOException {
- String index = req.getParameter("index");
- if (index == null) {
- throw new IOException("Missing parameter 'index'.");
- }
- int idx;
- try {
- idx = Integer.parseInt(index);
- } catch (NumberFormatException e) {
- throw new IOException("Invalid index: " + index);
- }
- req.findAncestorObject(Job.class).checkPermission(Run.UPDATE);
- Run, ?> run = req.findAncestorObject(Run.class);
- if (run != null) {
- List extends Action> actions = run.getAllActions();
- List extends Action> groovyActions = run.getActions(type);
- if (idx < 0 || idx >= groovyActions.size()) {
- throw new IOException("Index out of range: " + idx);
- }
- actions.remove(groovyActions.get(idx));
- run.save();
- rsp.sendRedirect(req.getRequestURI().substring(0, req.getRequestURI().indexOf("parent/parent")));
- }
- }
-
- public String translate(String text) throws IOException {
- return formatter.translate(text);
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.Extension;
+import hudson.markup.RawHtmlMarkupFormatter;
+import hudson.model.Action;
+import hudson.model.Job;
+import hudson.model.Run;
+import java.io.IOException;
+import java.util.List;
+import jenkins.model.GlobalConfiguration;
+import org.kohsuke.stapler.DataBoundSetter;
+import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.StaplerResponse;
+import org.kohsuke.stapler.interceptor.RequirePOST;
+
+@Extension
+public class BadgePlugin extends GlobalConfiguration {
+
+ /**
+ * @return the singleton instance
+ */
+ public static BadgePlugin get() {
+ return GlobalConfiguration.all().get(BadgePlugin.class);
+ }
+
+ private boolean disableFormatHTML;
+
+ private final RawHtmlMarkupFormatter formatter = new RawHtmlMarkupFormatter(false);
+
+ @SuppressFBWarnings(
+ value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
+ justification = "Common pattern in Jenkins constructors")
+ public BadgePlugin() {
+ // When Jenkins is restarted, load any saved configuration from disk.
+ load();
+ }
+
+ /**
+ * @return the whether HTML formatting is disabled or not
+ */
+ public boolean isDisableFormatHTML() {
+ return disableFormatHTML;
+ }
+
+ /**
+ * Together with {@link #isDisableFormatHTML}, binds to entry in {@code config.jelly}.
+ *
+ * @param disableFormatHTML the new value of this field
+ */
+ @DataBoundSetter
+ public void setDisableFormatHTML(boolean disableFormatHTML) {
+ this.disableFormatHTML = disableFormatHTML;
+ save();
+ }
+
+ @RequirePOST
+ public void doRemoveBadges(StaplerRequest req, StaplerResponse rsp) throws IOException {
+ removeActions(BadgeAction.class, req, rsp);
+ }
+
+ @RequirePOST
+ public void doRemoveSummaries(StaplerRequest req, StaplerResponse rsp) throws IOException {
+ removeActions(BadgeSummaryAction.class, req, rsp);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeActions(Class type, StaplerRequest req, StaplerResponse rsp) throws IOException {
+ req.findAncestorObject(Job.class).checkPermission(Run.UPDATE);
+ Run, ?> run = req.findAncestorObject(Run.class);
+ if (run != null) {
+ List extends Action> actions = run.getAllActions();
+ List groovyActions = run.getActions(type);
+ for (Action action : groovyActions) {
+ actions.remove(action);
+ }
+ run.save();
+ rsp.sendRedirect(
+ req.getRequestURI().substring(0, req.getRequestURI().indexOf("parent/parent")));
+ }
+ }
+
+ @RequirePOST
+ public void doRemoveBadge(StaplerRequest req, StaplerResponse rsp) throws IOException {
+ removeAction(BadgeAction.class, req, rsp);
+ }
+
+ @RequirePOST
+ public void doRemoveSummary(StaplerRequest req, StaplerResponse rsp) throws IOException {
+ removeAction(BadgeSummaryAction.class, req, rsp);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeAction(Class type, StaplerRequest req, StaplerResponse rsp) throws IOException {
+ String index = req.getParameter("index");
+ if (index == null) {
+ throw new IOException("Missing parameter 'index'.");
+ }
+ int idx;
+ try {
+ idx = Integer.parseInt(index);
+ } catch (NumberFormatException e) {
+ throw new IOException("Invalid index: " + index);
+ }
+ req.findAncestorObject(Job.class).checkPermission(Run.UPDATE);
+ Run, ?> run = req.findAncestorObject(Run.class);
+ if (run != null) {
+ List extends Action> actions = run.getAllActions();
+ List extends Action> groovyActions = run.getActions(type);
+ if (idx < 0 || idx >= groovyActions.size()) {
+ throw new IOException("Index out of range: " + idx);
+ }
+ actions.remove(groovyActions.get(idx));
+ run.save();
+ rsp.sendRedirect(
+ req.getRequestURI().substring(0, req.getRequestURI().indexOf("parent/parent")));
+ }
+ }
+
+ public String translate(String text) throws IOException {
+ return formatter.translate(text);
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractAction.java
index 1bbd2bd..8815247 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractAction.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractAction.java
@@ -26,82 +26,81 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.model.Action;
-import org.kohsuke.stapler.export.Exported;
-
import java.io.Serializable;
+import org.kohsuke.stapler.export.Exported;
/**
* An abstract action providing a badge id
*/
public abstract class AbstractAction implements Action, Serializable {
- private String id;
-
- public void setId(String id) {
- this.id = id;
- }
+ private String id;
- @Exported
- public String getId() {
- return id;
- }
-
- /**
- * Is the icon reference a Jenkins symbol name.
- * @param icon icon reference
- * @return {@code true} if the icon reference is a Jenkins symbol name
- */
- static boolean isJenkinsSymbolRef(@Nullable String icon) {
- return icon != null && icon.startsWith("symbol-");
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- /**
- * Get the Jenkins color class for the given color reference. Returns {@code null} if the color is not a
- * known Jenkins palette color or semantic color.
- * @param color color reference
- * @return jenkins color class name or {@code null}
- */
- @CheckForNull
- static String getJenkinsColorClass(@Nullable String color) {
- if (color == null) {
- return null;
+ @Exported
+ public String getId() {
+ return id;
}
- String primary = color;
- if (color.startsWith("light-") && color.length() > 6) {
- primary = color.substring(6);
- } else if (color.startsWith("dark-") && color.length() > 5) {
- primary = color.substring(5);
+ /**
+ * Is the icon reference a Jenkins symbol name.
+ * @param icon icon reference
+ * @return {@code true} if the icon reference is a Jenkins symbol name
+ */
+ static boolean isJenkinsSymbolRef(@Nullable String icon) {
+ return icon != null && icon.startsWith("symbol-");
}
- // https://github.com/jenkinsci/jenkins/blob/master/war/src/main/scss/abstracts/_theme.scss
- switch(primary) {
- // palette
- case "blue":
- case "brown":
- case "cyan":
- case "green":
- case "indigo":
- case "orange":
- case "pink":
- case "purple":
- case "red":
- case "yellow":
- case "white":
- case "black":
- return "jenkins-!-color-" + color;
- // semantics
- case "accent":
- case "text":
- case "error":
- case "warning":
- case "destructive":
- case "build":
- case "success":
- case "danger":
- case "info":
- return "jenkins-!-" + color + "-color";
- default:
- return null;
+ /**
+ * Get the Jenkins color class for the given color reference. Returns {@code null} if the color is not a
+ * known Jenkins palette color or semantic color.
+ * @param color color reference
+ * @return jenkins color class name or {@code null}
+ */
+ @CheckForNull
+ static String getJenkinsColorClass(@Nullable String color) {
+ if (color == null) {
+ return null;
+ }
+
+ String primary = color;
+ if (color.startsWith("light-") && color.length() > 6) {
+ primary = color.substring(6);
+ } else if (color.startsWith("dark-") && color.length() > 5) {
+ primary = color.substring(5);
+ }
+
+ // https://github.com/jenkinsci/jenkins/blob/master/war/src/main/scss/abstracts/_theme.scss
+ switch (primary) {
+ // palette
+ case "blue":
+ case "brown":
+ case "cyan":
+ case "green":
+ case "indigo":
+ case "orange":
+ case "pink":
+ case "purple":
+ case "red":
+ case "yellow":
+ case "white":
+ case "black":
+ return "jenkins-!-color-" + color;
+ // semantics
+ case "accent":
+ case "text":
+ case "error":
+ case "warning":
+ case "destructive":
+ case "build":
+ case "success":
+ case "danger":
+ case "info":
+ return "jenkins-!-" + color + "-color";
+ default:
+ return null;
+ }
}
- }
}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java
index f726c73..19e274a 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java
@@ -28,5 +28,4 @@
/**
* An abstract badge action providing a badge id
*/
-public abstract class AbstractBadgeAction extends AbstractAction implements BuildBadgeAction {
-}
+public abstract class AbstractBadgeAction extends AbstractAction implements BuildBadgeAction {}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/BadgeAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/BadgeAction.java
index fb16f02..ee7a4a1 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/action/BadgeAction.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/action/BadgeAction.java
@@ -1,266 +1,269 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.action;
-
-import com.jenkinsci.plugins.badge.BadgePlugin;
-import hudson.PluginWrapper;
-import hudson.model.Hudson;
-import io.jenkins.plugins.ionicons.Ionicons;
-import jenkins.model.Jenkins;
-import org.kohsuke.stapler.Stapler;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.export.Exported;
-import org.kohsuke.stapler.export.ExportedBean;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-@ExportedBean(defaultVisibility = 2)
-public class BadgeAction extends AbstractBadgeAction {
- private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
- private static final long serialVersionUID = 1L;
- private final String iconPath;
- private final String text;
- private String color;
- private String background;
- private String border;
- private String borderColor;
- private String link;
-
- private BadgeAction(String iconPath, String text) {
- this.iconPath = iconPath;
- this.text = text;
- }
-
- public static BadgeAction createBadge(String icon, String text) {
- return new BadgeAction(getIconPath(icon), text);
- }
-
- public static BadgeAction createBadge(String icon, String text, String link) throws IllegalArgumentException {
- BadgeAction action = new BadgeAction(getIconPath(icon), text);
- action.link = link;
- action.validate();
- return action;
- }
-
- public static BadgeAction createBadge(String icon, String color, String text, String link) throws IllegalArgumentException {
- BadgeAction action = new BadgeAction(getIconPath(icon), text);
- action.link = link;
- action.color = color;
- action.validate();
- return action;
- }
-
- public static BadgeAction createShortText(String text) {
- return new BadgeAction(null, text);
- }
-
-
- public static BadgeAction createShortText(String text, String color, String background, String border, String borderColor) {
- return createShortText(text, color, background, border, borderColor, null);
- }
-
- public static BadgeAction createShortText(String text, String color, String background, String border, String borderColor, String link) {
- BadgeAction action = new BadgeAction(null, text);
- action.color = color;
- action.background = background;
- action.border = border;
- action.borderColor = borderColor;
- action.link = link;
- return action;
- }
-
- public static BadgeAction createInfoBadge(String text) throws IllegalArgumentException {
- return createInfoBadge(text, null);
- }
-
- public static BadgeAction createInfoBadge(String text, String link) throws IllegalArgumentException {
- return createBadge(Ionicons.getIconClassName("information-circle"), "jenkins-!-color-blue", text, link);
- }
-
- public static BadgeAction createWarningBadge(String text) throws IllegalArgumentException {
- return createWarningBadge(text, null);
- }
-
- public static BadgeAction createWarningBadge(String text, String link) throws IllegalArgumentException {
- return createBadge(Ionicons.getIconClassName("warning"), "jenkins-!-warning-color", text, link);
- }
-
- public static BadgeAction createErrorBadge(String text) throws IllegalArgumentException {
- return createErrorBadge(text, null);
- }
-
- public static BadgeAction createErrorBadge(String text, String link) throws IllegalArgumentException {
- return createBadge(Ionicons.getIconClassName("remove-circle"), "jenkins-!-error-color", text, link);
- }
-
- protected void validate() throws IllegalArgumentException {
- if (BadgePlugin.get().isDisableFormatHTML()) {
- return;
- }
-
- if (link != null && !link.startsWith("/") && !link.matches("^https?:.*") && !link.matches("^mailto:.*")) {
- throw new IllegalArgumentException("Invalid link '" + link + "'for badge action with text '" + text + "'");
- }
- }
-
- /* Action methods */
- public String getUrlName() {
- return "";
- }
-
- public String getDisplayName() {
- return "";
- }
-
- public String getIconFileName() {
- return null;
- }
-
- @Exported
- public boolean isTextOnly() {
- return (iconPath == null);
- }
-
- @Exported
- public String getIconPath() {
- // add the context path to the path variable if the image starts with /
- if (iconPath != null && iconPath.startsWith("/")) {
- StaplerRequest currentRequest = Stapler.getCurrentRequest();
- if (currentRequest != null && !iconPath.startsWith(currentRequest.getContextPath())) {
- return currentRequest.getContextPath() + iconPath;
- }
- }
- return iconPath;
- }
-
- @Exported
- public String getText() {
- if (BadgePlugin.get().isDisableFormatHTML()) {
- return text;
- }
- try {
- return BadgePlugin.get().translate(text);
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "Error preparing badge text for ui", e);
- return "ERROR";
- }
- }
-
- @Exported
- public String getColor() {
- return color;
- }
-
- @Exported
- public String getBackground() {
- return background;
- }
-
- @Exported
- public String getBorder() {
- return border;
- }
-
- @Exported
- public String getBorderColor() {
- return borderColor;
- }
-
- /**
- * Get the class value for the icon element.
- * @return string of css class names to add or empty string if no class to add.
- */
- public String getIconClass() {
- List classes = new LinkedList<>();
- if (isJenkinsSymbolRef(this.iconPath)) {
- classes.add("icon-sm");
- }
-
- if (this.color != null) {
- if (this.color.startsWith("jenkins-!-")) {
- classes.add(this.color);
- } else {
- String colorClass = getJenkinsColorClass(this.color);
- if (colorClass != null) {
- classes.add(colorClass);
- }
- }
- }
-
- return String.join(" ", classes);
- }
-
- /**
- * Get the color value for the {@code style} attribute of the icon element.
- * @return {@code null} if color not set or color is a Jenkins color class.
- */
- public String getIconColorStyle() {
- if (this.color != null && !this.color.startsWith("jenkins-!-") && getJenkinsColorClass(this.color) == null) {
- return this.color;
- }
-
- return null;
- }
-
- @Exported
- public String getLink() {
- if (link == null || BadgePlugin.get().isDisableFormatHTML()) {
- return link;
- }
-
- if (link.startsWith("/") || link.matches("^https?:.*") || link.matches("^mailto:.*")) {
- return link;
- }
- LOGGER.log(Level.WARNING, "Error invalid link value: '" + link + "'");
-
- return null;
- }
-
- public static String getIconPath(String icon) {
- if (icon == null) {
- return null;
- }
-
- if (icon.startsWith("/") || icon.matches("^https?:.*")) {
- return icon;
- }
-
- if (isJenkinsSymbolRef(icon)) {
- return icon;
- }
-
- Jenkins jenkins = Jenkins.getInstanceOrNull();
-
- // Try plugin images dir, fallback to Hudson images dir
- PluginWrapper wrapper = jenkins != null ? jenkins.getPluginManager().getPlugin("badge") : null;
- boolean pluginIconExists = (wrapper != null) && new File(wrapper.baseResourceURL.getPath() + "/images/" + icon).exists();
- return pluginIconExists ? "/plugin/" + wrapper.getShortName() + "/images/" + icon : Hudson.RESOURCE_PATH + "/images/16x16/" + icon;
- }
-
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.action;
+
+import com.jenkinsci.plugins.badge.BadgePlugin;
+import hudson.PluginWrapper;
+import hudson.model.Hudson;
+import io.jenkins.plugins.ionicons.Ionicons;
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import jenkins.model.Jenkins;
+import org.kohsuke.stapler.Stapler;
+import org.kohsuke.stapler.StaplerRequest;
+import org.kohsuke.stapler.export.Exported;
+import org.kohsuke.stapler.export.ExportedBean;
+
+@ExportedBean(defaultVisibility = 2)
+public class BadgeAction extends AbstractBadgeAction {
+ private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
+ private static final long serialVersionUID = 1L;
+ private final String iconPath;
+ private final String text;
+ private String color;
+ private String background;
+ private String border;
+ private String borderColor;
+ private String link;
+
+ private BadgeAction(String iconPath, String text) {
+ this.iconPath = iconPath;
+ this.text = text;
+ }
+
+ public static BadgeAction createBadge(String icon, String text) {
+ return new BadgeAction(getIconPath(icon), text);
+ }
+
+ public static BadgeAction createBadge(String icon, String text, String link) throws IllegalArgumentException {
+ BadgeAction action = new BadgeAction(getIconPath(icon), text);
+ action.link = link;
+ action.validate();
+ return action;
+ }
+
+ public static BadgeAction createBadge(String icon, String color, String text, String link)
+ throws IllegalArgumentException {
+ BadgeAction action = new BadgeAction(getIconPath(icon), text);
+ action.link = link;
+ action.color = color;
+ action.validate();
+ return action;
+ }
+
+ public static BadgeAction createShortText(String text) {
+ return new BadgeAction(null, text);
+ }
+
+ public static BadgeAction createShortText(
+ String text, String color, String background, String border, String borderColor) {
+ return createShortText(text, color, background, border, borderColor, null);
+ }
+
+ public static BadgeAction createShortText(
+ String text, String color, String background, String border, String borderColor, String link) {
+ BadgeAction action = new BadgeAction(null, text);
+ action.color = color;
+ action.background = background;
+ action.border = border;
+ action.borderColor = borderColor;
+ action.link = link;
+ return action;
+ }
+
+ public static BadgeAction createInfoBadge(String text) throws IllegalArgumentException {
+ return createInfoBadge(text, null);
+ }
+
+ public static BadgeAction createInfoBadge(String text, String link) throws IllegalArgumentException {
+ return createBadge(Ionicons.getIconClassName("information-circle"), "jenkins-!-color-blue", text, link);
+ }
+
+ public static BadgeAction createWarningBadge(String text) throws IllegalArgumentException {
+ return createWarningBadge(text, null);
+ }
+
+ public static BadgeAction createWarningBadge(String text, String link) throws IllegalArgumentException {
+ return createBadge(Ionicons.getIconClassName("warning"), "jenkins-!-warning-color", text, link);
+ }
+
+ public static BadgeAction createErrorBadge(String text) throws IllegalArgumentException {
+ return createErrorBadge(text, null);
+ }
+
+ public static BadgeAction createErrorBadge(String text, String link) throws IllegalArgumentException {
+ return createBadge(Ionicons.getIconClassName("remove-circle"), "jenkins-!-error-color", text, link);
+ }
+
+ protected void validate() throws IllegalArgumentException {
+ if (BadgePlugin.get().isDisableFormatHTML()) {
+ return;
+ }
+
+ if (link != null && !link.startsWith("/") && !link.matches("^https?:.*") && !link.matches("^mailto:.*")) {
+ throw new IllegalArgumentException("Invalid link '" + link + "'for badge action with text '" + text + "'");
+ }
+ }
+
+ /* Action methods */
+ public String getUrlName() {
+ return "";
+ }
+
+ public String getDisplayName() {
+ return "";
+ }
+
+ public String getIconFileName() {
+ return null;
+ }
+
+ @Exported
+ public boolean isTextOnly() {
+ return (iconPath == null);
+ }
+
+ @Exported
+ public String getIconPath() {
+ // add the context path to the path variable if the image starts with /
+ if (iconPath != null && iconPath.startsWith("/")) {
+ StaplerRequest currentRequest = Stapler.getCurrentRequest();
+ if (currentRequest != null && !iconPath.startsWith(currentRequest.getContextPath())) {
+ return currentRequest.getContextPath() + iconPath;
+ }
+ }
+ return iconPath;
+ }
+
+ @Exported
+ public String getText() {
+ if (BadgePlugin.get().isDisableFormatHTML()) {
+ return text;
+ }
+ try {
+ return BadgePlugin.get().translate(text);
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, "Error preparing badge text for ui", e);
+ return "ERROR";
+ }
+ }
+
+ @Exported
+ public String getColor() {
+ return color;
+ }
+
+ @Exported
+ public String getBackground() {
+ return background;
+ }
+
+ @Exported
+ public String getBorder() {
+ return border;
+ }
+
+ @Exported
+ public String getBorderColor() {
+ return borderColor;
+ }
+
+ /**
+ * Get the class value for the icon element.
+ * @return string of css class names to add or empty string if no class to add.
+ */
+ public String getIconClass() {
+ List classes = new LinkedList<>();
+ if (isJenkinsSymbolRef(this.iconPath)) {
+ classes.add("icon-sm");
+ }
+
+ if (this.color != null) {
+ if (this.color.startsWith("jenkins-!-")) {
+ classes.add(this.color);
+ } else {
+ String colorClass = getJenkinsColorClass(this.color);
+ if (colorClass != null) {
+ classes.add(colorClass);
+ }
+ }
+ }
+
+ return String.join(" ", classes);
+ }
+
+ /**
+ * Get the color value for the {@code style} attribute of the icon element.
+ * @return {@code null} if color not set or color is a Jenkins color class.
+ */
+ public String getIconColorStyle() {
+ if (this.color != null && !this.color.startsWith("jenkins-!-") && getJenkinsColorClass(this.color) == null) {
+ return this.color;
+ }
+
+ return null;
+ }
+
+ @Exported
+ public String getLink() {
+ if (link == null || BadgePlugin.get().isDisableFormatHTML()) {
+ return link;
+ }
+
+ if (link.startsWith("/") || link.matches("^https?:.*") || link.matches("^mailto:.*")) {
+ return link;
+ }
+ LOGGER.log(Level.WARNING, "Error invalid link value: '" + link + "'");
+
+ return null;
+ }
+
+ public static String getIconPath(String icon) {
+ if (icon == null) {
+ return null;
+ }
+
+ if (icon.startsWith("/") || icon.matches("^https?:.*")) {
+ return icon;
+ }
+
+ if (isJenkinsSymbolRef(icon)) {
+ return icon;
+ }
+
+ Jenkins jenkins = Jenkins.getInstanceOrNull();
+
+ // Try plugin images dir, fallback to Hudson images dir
+ PluginWrapper wrapper = jenkins != null ? jenkins.getPluginManager().getPlugin("badge") : null;
+ boolean pluginIconExists =
+ (wrapper != null) && new File(wrapper.baseResourceURL.getPath() + "/images/" + icon).exists();
+ return pluginIconExists
+ ? "/plugin/" + wrapper.getShortName() + "/images/" + icon
+ : Hudson.RESOURCE_PATH + "/images/16x16/" + icon;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/BadgeSummaryAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/BadgeSummaryAction.java
index 1df04d3..161ad98 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/action/BadgeSummaryAction.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/action/BadgeSummaryAction.java
@@ -1,123 +1,121 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.action;
-
-import com.jenkinsci.plugins.badge.BadgePlugin;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
-import org.kohsuke.stapler.export.Exported;
-import org.kohsuke.stapler.export.ExportedBean;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-@ExportedBean(defaultVisibility = 2)
-public class BadgeSummaryAction extends AbstractAction {
- private static final long serialVersionUID = 1L;
- private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
-
- private final String iconPath;
- private String summaryText = "";
-
- public BadgeSummaryAction(String iconPath) {
- this.iconPath = iconPath;
- }
-
- /* Action methods */
- public String getUrlName() {
- return "";
- }
-
- public String getDisplayName() {
- return "";
- }
-
- public String getIconFileName() {
- return null;
- }
-
- @Exported
- public String getIconPath() {
- return iconPath;
- }
-
- public String getRawText() {
- return summaryText;
- }
-
- @Exported
- public String getText() {
- if (BadgePlugin.get().isDisableFormatHTML()) {
- return summaryText;
- }
- try {
- return BadgePlugin.get().translate(summaryText);
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "Error preparing summary text for ui", e);
- return "ERROR";
- }
- }
-
- @Whitelisted
- public void appendText(String text) {
- appendText(text, false);
- }
-
- @Whitelisted
- public void appendText(String text, boolean escapeHtml) {
- if (escapeHtml) {
- text = StringEscapeUtils.escapeHtml(text);
- }
- summaryText += text;
- }
-
- @Whitelisted
- public void appendText(String text, boolean escapeHtml, boolean bold, boolean italic, String color) {
- String closeTags = "";
- if (bold) {
- summaryText += "";
- closeTags += "";
- }
- if (italic) {
- summaryText += "";
- closeTags += "";
- }
- if (color != null) {
- String cls = getJenkinsColorClass(color);
- if (cls != null) {
- summaryText += "";
- closeTags += "";
- } else {
- summaryText += "";
- closeTags += "";
- }
- }
- if (escapeHtml) {
- text = StringEscapeUtils.escapeHtml(text);
- }
- summaryText += text + closeTags;
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.action;
+
+import com.jenkinsci.plugins.badge.BadgePlugin;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
+import org.kohsuke.stapler.export.Exported;
+import org.kohsuke.stapler.export.ExportedBean;
+
+@ExportedBean(defaultVisibility = 2)
+public class BadgeSummaryAction extends AbstractAction {
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
+
+ private final String iconPath;
+ private String summaryText = "";
+
+ public BadgeSummaryAction(String iconPath) {
+ this.iconPath = iconPath;
+ }
+
+ /* Action methods */
+ public String getUrlName() {
+ return "";
+ }
+
+ public String getDisplayName() {
+ return "";
+ }
+
+ public String getIconFileName() {
+ return null;
+ }
+
+ @Exported
+ public String getIconPath() {
+ return iconPath;
+ }
+
+ public String getRawText() {
+ return summaryText;
+ }
+
+ @Exported
+ public String getText() {
+ if (BadgePlugin.get().isDisableFormatHTML()) {
+ return summaryText;
+ }
+ try {
+ return BadgePlugin.get().translate(summaryText);
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, "Error preparing summary text for ui", e);
+ return "ERROR";
+ }
+ }
+
+ @Whitelisted
+ public void appendText(String text) {
+ appendText(text, false);
+ }
+
+ @Whitelisted
+ public void appendText(String text, boolean escapeHtml) {
+ if (escapeHtml) {
+ text = StringEscapeUtils.escapeHtml(text);
+ }
+ summaryText += text;
+ }
+
+ @Whitelisted
+ public void appendText(String text, boolean escapeHtml, boolean bold, boolean italic, String color) {
+ String closeTags = "";
+ if (bold) {
+ summaryText += "";
+ closeTags += "";
+ }
+ if (italic) {
+ summaryText += "";
+ closeTags += "";
+ }
+ if (color != null) {
+ String cls = getJenkinsColorClass(color);
+ if (cls != null) {
+ summaryText += "";
+ closeTags += "";
+ } else {
+ summaryText += "";
+ closeTags += "";
+ }
+ }
+ if (escapeHtml) {
+ text = StringEscapeUtils.escapeHtml(text);
+ }
+ summaryText += text + closeTags;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/HtmlBadgeAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/HtmlBadgeAction.java
index d5d420d..d1a0716 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/action/HtmlBadgeAction.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/action/HtmlBadgeAction.java
@@ -1,78 +1,77 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.action;
-
-import com.jenkinsci.plugins.badge.BadgePlugin;
-import org.kohsuke.stapler.export.Exported;
-import org.kohsuke.stapler.export.ExportedBean;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-@ExportedBean(defaultVisibility = 2)
-public class HtmlBadgeAction extends AbstractBadgeAction {
- private static final long serialVersionUID = 1L;
- private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
-
- private final String html;
-
- private HtmlBadgeAction(String html) {
- this.html = html;
- }
-
- public static HtmlBadgeAction createHtmlBadge(String html) {
- return new HtmlBadgeAction(html);
- }
-
- /* Action methods */
- public String getUrlName() {
- return "";
- }
-
- public String getDisplayName() {
- return "";
- }
-
- public String getIconFileName() {
- return null;
- }
-
- public String getRawHtml() {
- return html;
- }
-
- @Exported
- public String getHtml() {
- if (BadgePlugin.get().isDisableFormatHTML()) {
- return html;
- }
- try {
- return BadgePlugin.get().translate(html);
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "Error preparing html content for ui", e);
- return "ERROR";
- }
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.action;
+
+import com.jenkinsci.plugins.badge.BadgePlugin;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.kohsuke.stapler.export.Exported;
+import org.kohsuke.stapler.export.ExportedBean;
+
+@ExportedBean(defaultVisibility = 2)
+public class HtmlBadgeAction extends AbstractBadgeAction {
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOGGER = Logger.getLogger(BadgeSummaryAction.class.getName());
+
+ private final String html;
+
+ private HtmlBadgeAction(String html) {
+ this.html = html;
+ }
+
+ public static HtmlBadgeAction createHtmlBadge(String html) {
+ return new HtmlBadgeAction(html);
+ }
+
+ /* Action methods */
+ public String getUrlName() {
+ return "";
+ }
+
+ public String getDisplayName() {
+ return "";
+ }
+
+ public String getIconFileName() {
+ return null;
+ }
+
+ public String getRawHtml() {
+ return html;
+ }
+
+ @Exported
+ public String getHtml() {
+ if (BadgePlugin.get().isDisableFormatHTML()) {
+ return html;
+ }
+ try {
+ return BadgePlugin.get().translate(html);
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, "Error preparing html content for ui", e);
+ return "ERROR";
+ }
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java
index 4626960..c5e94bf 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java
@@ -1,139 +1,137 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2024, Badge Plugin Authors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import hudson.model.Run;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
-import org.kohsuke.stapler.DataBoundSetter;
-
-import java.io.Serializable;
-
-/**
- * Abstract class to add badges.
- */
-public abstract class AbstractAddBadgeStep extends AbstractStep {
-
- private final Badge badge;
-
- /**
- * @param icon The icon for this badge
- * @param text The text for this badge
- */
- public AbstractAddBadgeStep(String icon, String text) {
- this.badge = new Badge(icon, text);
- }
-
- public String getIcon() {
- return badge.getIcon();
- }
-
- public String getText() {
- return badge.getText();
- }
-
- public String getLink() {
- return badge.getLink();
- }
-
- /**
- * @param link The link to be added to this badge
- */
- @DataBoundSetter
- public void setLink(String link) {
- badge.setLink(link);
- }
-
- protected Badge getBadge() {
- return badge;
- }
-
- protected static class Badge implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private final String icon;
- private final String text;
- private String link;
- private String color;
-
- private Badge(String icon, String text) {
- this.icon = icon;
- this.text = text;
- }
-
- protected String getIcon() {
- return icon;
- }
-
- protected String getText() {
- return text;
- }
-
- protected String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- protected String getColor() {
- return color;
- }
-
- public void setColor(String color) {
- this.color = color;
- }
- }
-
- static abstract class Execution extends SynchronousStepExecution {
-
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final Badge badge;
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final String id;
-
- Execution(Badge badge, String id, StepContext context) {
- super(context);
- this.badge = badge;
- this.id = id;
- }
-
- @Override
- protected Void run() throws Exception {
- BadgeAction action = newBatchAction(badge);
- action.setId(id);
- getContext().get(Run.class).addAction(action);
- return null;
- }
-
- protected abstract BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException;
-
- private static final long serialVersionUID = 1L;
-
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2024, Badge Plugin Authors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.model.Run;
+import java.io.Serializable;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
+import org.kohsuke.stapler.DataBoundSetter;
+
+/**
+ * Abstract class to add badges.
+ */
+public abstract class AbstractAddBadgeStep extends AbstractStep {
+
+ private final Badge badge;
+
+ /**
+ * @param icon The icon for this badge
+ * @param text The text for this badge
+ */
+ public AbstractAddBadgeStep(String icon, String text) {
+ this.badge = new Badge(icon, text);
+ }
+
+ public String getIcon() {
+ return badge.getIcon();
+ }
+
+ public String getText() {
+ return badge.getText();
+ }
+
+ public String getLink() {
+ return badge.getLink();
+ }
+
+ /**
+ * @param link The link to be added to this badge
+ */
+ @DataBoundSetter
+ public void setLink(String link) {
+ badge.setLink(link);
+ }
+
+ protected Badge getBadge() {
+ return badge;
+ }
+
+ protected static class Badge implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final String icon;
+ private final String text;
+ private String link;
+ private String color;
+
+ private Badge(String icon, String text) {
+ this.icon = icon;
+ this.text = text;
+ }
+
+ protected String getIcon() {
+ return icon;
+ }
+
+ protected String getText() {
+ return text;
+ }
+
+ protected String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ protected String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+ }
+
+ abstract static class Execution extends SynchronousStepExecution {
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient Badge badge;
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient String id;
+
+ Execution(Badge badge, String id, StepContext context) {
+ super(context);
+ this.badge = badge;
+ this.id = id;
+ }
+
+ @Override
+ protected Void run() throws Exception {
+ BadgeAction action = newBatchAction(badge);
+ action.setId(id);
+ getContext().get(Run.class).addAction(action);
+ return null;
+ }
+
+ protected abstract BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException;
+
+ private static final long serialVersionUID = 1L;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractRemoveBadgesStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractRemoveBadgesStep.java
index 56abb41..3babe99 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractRemoveBadgesStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractRemoveBadgesStep.java
@@ -27,53 +27,50 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.Action;
import hudson.model.Run;
+import java.io.IOException;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.steps.StepExecution;
import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
-import java.io.IOException;
-
/**
* Abstract class to remove badges
*/
abstract class AbstractRemoveBadgesStep extends AbstractStep {
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(context, getActionClass(), getId());
- }
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(context, getActionClass(), getId());
+ }
+ protected abstract Class extends AbstractAction> getActionClass();
- protected abstract Class extends AbstractAction> getActionClass();
+ public static class Execution extends SynchronousStepExecution {
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final Class extends AbstractAction> actionClass;
- public static class Execution extends SynchronousStepExecution {
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final String id;
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private final Class extends AbstractAction> actionClass;
+ Execution(StepContext context, Class extends AbstractAction> actionClass, String id) {
+ super(context);
+ this.actionClass = actionClass;
+ this.id = id;
+ }
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private final String id;
+ @Override
+ protected Void run() throws IOException, InterruptedException {
+ Run, ?> run = getContext().get(Run.class);
+ if (run != null) {
+ run.getAllActions().stream().filter(this::matches).forEach(run::removeAction);
+ }
+ return null;
+ }
- Execution(StepContext context, Class extends AbstractAction> actionClass, String id) {
- super(context);
- this.actionClass = actionClass;
- this.id = id;
- }
+ private boolean matches(Action a) {
+ return actionClass.isAssignableFrom(a.getClass())
+ && (id == null || id.equals(((AbstractAction) a).getId()));
+ }
- @Override
- protected Void run() throws IOException, InterruptedException {
- Run, ?> run = getContext().get(Run.class);
- if (run != null) {
- run.getAllActions().stream().filter(this::matches).forEach(run::removeAction);
- }
- return null;
- }
-
- private boolean matches(Action a) {
- return actionClass.isAssignableFrom(a.getClass()) && (id == null || id.equals(((AbstractAction) a).getId()));
+ private static final long serialVersionUID = 1L;
}
-
- private static final long serialVersionUID = 1L;
-
- }
}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractStep.java
index fced38b..3795cb8 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractStep.java
@@ -30,18 +30,17 @@
* An abstract Step implementation providing an id for the step.
*/
abstract class AbstractStep extends Step {
- private String id;
+ private String id;
- /**
- * @param id Badge identifier. Selectively delete badges by id.
- */
- @DataBoundSetter
- public void setId(String id) {
- this.id = id;
- }
+ /**
+ * @param id Badge identifier. Selectively delete badges by id.
+ */
+ @DataBoundSetter
+ public void setId(String id) {
+ this.id = id;
+ }
- public String getId() {
- return id;
- }
+ public String getId() {
+ return id;
+ }
}
-
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractTaskListenerDescriptor.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractTaskListenerDescriptor.java
index 5d6e801..111e214 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractTaskListenerDescriptor.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractTaskListenerDescriptor.java
@@ -1,40 +1,39 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import hudson.model.TaskListener;
-import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
-
-import java.util.HashSet;
-import java.util.Set;
-
-abstract class AbstractTaskListenerDescriptor extends StepDescriptor {
-
- @Override
- public Set> getRequiredContext() {
- Set> set = new HashSet<>();
- set.add(TaskListener.class);
- return set;
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import hudson.model.TaskListener;
+import java.util.HashSet;
+import java.util.Set;
+import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
+
+abstract class AbstractTaskListenerDescriptor extends StepDescriptor {
+
+ @Override
+ public Set> getRequiredContext() {
+ Set> set = new HashSet<>();
+ set.add(TaskListener.class);
+ return set;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java
index 6b928c2..482844b 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java
@@ -1,87 +1,85 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import hudson.Extension;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.DataBoundSetter;
-
-/**
- * Add a badge.
- */
-public class AddBadgeStep extends AbstractAddBadgeStep {
-
- /**
- * @param icon The icon for this badge
- * @param text The text for this badge
- */
- @DataBoundConstructor
- public AddBadgeStep(String icon, String text) {
- super(icon, text);
- }
-
- public String getColor() {
- return getBadge().getColor();
- }
-
- /**
- * @param color The Jenkins palette/semantic color name of the badge icon symbol
- */
- @DataBoundSetter
- public void setColor(String color) {
- getBadge().setColor(color);
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(getBadge(), getId(), context) {
-
- @Override
- protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
- return BadgeAction.createBadge(badge.getIcon(), badge.getColor(), badge.getText(), badge.getLink());
- }
- };
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addBadge";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add Badge";
- }
-
- }
-
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import hudson.Extension;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.kohsuke.stapler.DataBoundSetter;
+
+/**
+ * Add a badge.
+ */
+public class AddBadgeStep extends AbstractAddBadgeStep {
+
+ /**
+ * @param icon The icon for this badge
+ * @param text The text for this badge
+ */
+ @DataBoundConstructor
+ public AddBadgeStep(String icon, String text) {
+ super(icon, text);
+ }
+
+ public String getColor() {
+ return getBadge().getColor();
+ }
+
+ /**
+ * @param color The Jenkins palette/semantic color name of the badge icon symbol
+ */
+ @DataBoundSetter
+ public void setColor(String color) {
+ getBadge().setColor(color);
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(getBadge(), getId(), context) {
+
+ @Override
+ protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
+ return BadgeAction.createBadge(badge.getIcon(), badge.getColor(), badge.getText(), badge.getLink());
+ }
+ };
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addBadge";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add Badge";
+ }
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddErrorBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddErrorBadgeStep.java
index a87ecf4..3e37cc9 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddErrorBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddErrorBadgeStep.java
@@ -1,72 +1,71 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import hudson.Extension;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-
-/**
- * Add an error badge.
- */
-public class AddErrorBadgeStep extends AbstractAddBadgeStep {
-
- /**
- * @param text The text for this error badge
- */
- @DataBoundConstructor
- public AddErrorBadgeStep(String text) {
- super(null, text);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addErrorBadge";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add Error Badge";
- }
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(getBadge(), getId(), context) {
-
- @Override
- protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
- return BadgeAction.createErrorBadge(badge.getText(), badge.getLink());
- }
- };
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import hudson.Extension;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+
+/**
+ * Add an error badge.
+ */
+public class AddErrorBadgeStep extends AbstractAddBadgeStep {
+
+ /**
+ * @param text The text for this error badge
+ */
+ @DataBoundConstructor
+ public AddErrorBadgeStep(String text) {
+ super(null, text);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addErrorBadge";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add Error Badge";
+ }
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(getBadge(), getId(), context) {
+
+ @Override
+ protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
+ return BadgeAction.createErrorBadge(badge.getText(), badge.getLink());
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStep.java
index d9d89a0..e2eb645 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStep.java
@@ -1,102 +1,100 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.HtmlBadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import hudson.Extension;
-import hudson.model.Run;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-
-/**
- * Create a short text.
- */
-public class AddHtmlBadgeStep extends AbstractStep {
-
- private final String html;
-
- /**
- *
- * @param html The html content to be used for this badge
- */
- @DataBoundConstructor
- public AddHtmlBadgeStep(String html) {
- this.html = html;
- }
-
- public String getHtml() {
- return html;
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(html, getId(), context);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addHtmlBadge";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add a html badge Text";
- }
-
- }
-
- public static class Execution extends SynchronousStepExecution {
-
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final String html;
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final String id;
-
- Execution(String html, String id, StepContext context) {
- super(context);
- this.html = html;
- this.id = id;
- }
-
- @Override
- protected Void run() throws Exception {
- HtmlBadgeAction htmlBadge = HtmlBadgeAction.createHtmlBadge(html);
- htmlBadge.setId(id);
- getContext().get(Run.class).addAction(htmlBadge);
- return null;
- }
-
- private static final long serialVersionUID = 1L;
-
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.HtmlBadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.Extension;
+import hudson.model.Run;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+
+/**
+ * Create a short text.
+ */
+public class AddHtmlBadgeStep extends AbstractStep {
+
+ private final String html;
+
+ /**
+ *
+ * @param html The html content to be used for this badge
+ */
+ @DataBoundConstructor
+ public AddHtmlBadgeStep(String html) {
+ this.html = html;
+ }
+
+ public String getHtml() {
+ return html;
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(html, getId(), context);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addHtmlBadge";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add a html badge Text";
+ }
+ }
+
+ public static class Execution extends SynchronousStepExecution {
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient String html;
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient String id;
+
+ Execution(String html, String id, StepContext context) {
+ super(context);
+ this.html = html;
+ this.id = id;
+ }
+
+ @Override
+ protected Void run() throws Exception {
+ HtmlBadgeAction htmlBadge = HtmlBadgeAction.createHtmlBadge(html);
+ htmlBadge.setId(id);
+ getContext().get(Run.class).addAction(htmlBadge);
+ return null;
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddInfoBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddInfoBadgeStep.java
index 15224e9..86824c3 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddInfoBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddInfoBadgeStep.java
@@ -1,72 +1,71 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import hudson.Extension;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-
-/**
- * Add an error badge.
- */
-public class AddInfoBadgeStep extends AbstractAddBadgeStep {
-
- /**
- * @param text The info text for this badge
- */
- @DataBoundConstructor
- public AddInfoBadgeStep(String text) {
- super(null, text);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addInfoBadge";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add Info Badge";
- }
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(getBadge(), getId(), context) {
-
- @Override
- protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
- return BadgeAction.createInfoBadge(badge.getText(), badge.getLink());
- }
- };
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import hudson.Extension;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+
+/**
+ * Add an error badge.
+ */
+public class AddInfoBadgeStep extends AbstractAddBadgeStep {
+
+ /**
+ * @param text The info text for this badge
+ */
+ @DataBoundConstructor
+ public AddInfoBadgeStep(String text) {
+ super(null, text);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addInfoBadge";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add Info Badge";
+ }
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(getBadge(), getId(), context) {
+
+ @Override
+ protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
+ return BadgeAction.createInfoBadge(badge.getText(), badge.getLink());
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddShortTextStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddShortTextStep.java
index 6da8b99..a941a9f 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddShortTextStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddShortTextStep.java
@@ -1,224 +1,227 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import hudson.Extension;
-import hudson.model.Run;
-import org.jenkinsci.plugins.workflow.steps.Step;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.DataBoundSetter;
-
-import java.io.Serializable;
-
-/**
- * Create a short text.
- */
-public class AddShortTextStep extends Step {
-
- private final ShortText shortText;
-
- /**
- * @param text The text to add fot this badge
- */
- @DataBoundConstructor
- public AddShortTextStep(String text) {
- this.shortText = new ShortText(text);
- }
-
- public String getText() {
- return shortText.getText();
- }
-
- public String getColor() {
- return shortText.getColor();
- }
-
- /**
- * @param color The color for this short text
- */
- @DataBoundSetter
- public void setColor(String color) {
- this.shortText.setColor(color);
- }
-
- public String getBackground() {
- return shortText.getBackground();
- }
-
- /**
- * @param background The background-color for this short text
- */
- @DataBoundSetter
- public void setBackground(String background) {
- this.shortText.setBackground(background);
- }
-
- public Integer getBorder() {
- return shortText.getBorder();
- }
-
- /**
- * @param border The border width for this short text
- */
- @DataBoundSetter
- public void setBorder(Integer border) {
- this.shortText.setBorder(border);
- }
-
- public String getBorderColor() {
- return shortText.getBorderColor();
- }
-
- /**
- * @param borderColor The order color for this short text
- */
- @DataBoundSetter
- public void setBorderColor(String borderColor) {
- this.shortText.setBorderColor(borderColor);
- }
-
- /**
- * @param link The link for this short text
- */
- @DataBoundSetter
- public void setLink(String link) {
- this.shortText.setLink(link);
- }
-
- public String getLink() {
- return this.shortText.getLink();
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(shortText, context);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addShortText";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add Short Text";
- }
-
- }
-
- private static class ShortText implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private final String text;
- private String color;
- private String background;
- private Integer border;
- private String borderColor;
- private String link;
-
- public ShortText(String text) {
- this.text = text;
- }
-
- private String getText() {
- return text;
- }
-
- private String getColor() {
- return color;
- }
-
- public void setColor(String color) {
- this.color = color;
- }
-
- private String getBackground() {
- return background;
- }
-
- public void setBackground(String background) {
- this.background = background;
- }
-
- private Integer getBorder() {
- return border;
- }
-
- public void setBorder(Integer border) {
- this.border = border;
- }
-
- private String getBorderColor() {
- return borderColor;
- }
-
- public void setBorderColor(String borderColor) {
- this.borderColor = borderColor;
- }
-
- private String getBorderString() {
- return border == null ? null : border + "px";
- }
-
- public String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
- }
-
- public static class Execution extends SynchronousStepExecution {
-
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final ShortText shortText;
-
- Execution(ShortText shortText, StepContext context) {
- super(context);
- this.shortText = shortText;
- }
-
- @Override
- protected Void run() throws Exception {
- getContext().get(Run.class).addAction(BadgeAction.createShortText(shortText.getText(),
- shortText.getColor(), shortText.getBackground(), shortText.getBorderString(), shortText.getBorderColor(), shortText.link));
- return null;
- }
-
- private static final long serialVersionUID = 1L;
-
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.Extension;
+import hudson.model.Run;
+import java.io.Serializable;
+import org.jenkinsci.plugins.workflow.steps.Step;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.kohsuke.stapler.DataBoundSetter;
+
+/**
+ * Create a short text.
+ */
+public class AddShortTextStep extends Step {
+
+ private final ShortText shortText;
+
+ /**
+ * @param text The text to add fot this badge
+ */
+ @DataBoundConstructor
+ public AddShortTextStep(String text) {
+ this.shortText = new ShortText(text);
+ }
+
+ public String getText() {
+ return shortText.getText();
+ }
+
+ public String getColor() {
+ return shortText.getColor();
+ }
+
+ /**
+ * @param color The color for this short text
+ */
+ @DataBoundSetter
+ public void setColor(String color) {
+ this.shortText.setColor(color);
+ }
+
+ public String getBackground() {
+ return shortText.getBackground();
+ }
+
+ /**
+ * @param background The background-color for this short text
+ */
+ @DataBoundSetter
+ public void setBackground(String background) {
+ this.shortText.setBackground(background);
+ }
+
+ public Integer getBorder() {
+ return shortText.getBorder();
+ }
+
+ /**
+ * @param border The border width for this short text
+ */
+ @DataBoundSetter
+ public void setBorder(Integer border) {
+ this.shortText.setBorder(border);
+ }
+
+ public String getBorderColor() {
+ return shortText.getBorderColor();
+ }
+
+ /**
+ * @param borderColor The order color for this short text
+ */
+ @DataBoundSetter
+ public void setBorderColor(String borderColor) {
+ this.shortText.setBorderColor(borderColor);
+ }
+
+ /**
+ * @param link The link for this short text
+ */
+ @DataBoundSetter
+ public void setLink(String link) {
+ this.shortText.setLink(link);
+ }
+
+ public String getLink() {
+ return this.shortText.getLink();
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(shortText, context);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addShortText";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add Short Text";
+ }
+ }
+
+ private static class ShortText implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final String text;
+ private String color;
+ private String background;
+ private Integer border;
+ private String borderColor;
+ private String link;
+
+ public ShortText(String text) {
+ this.text = text;
+ }
+
+ private String getText() {
+ return text;
+ }
+
+ private String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ private String getBackground() {
+ return background;
+ }
+
+ public void setBackground(String background) {
+ this.background = background;
+ }
+
+ private Integer getBorder() {
+ return border;
+ }
+
+ public void setBorder(Integer border) {
+ this.border = border;
+ }
+
+ private String getBorderColor() {
+ return borderColor;
+ }
+
+ public void setBorderColor(String borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ private String getBorderString() {
+ return border == null ? null : border + "px";
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+ }
+
+ public static class Execution extends SynchronousStepExecution {
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient ShortText shortText;
+
+ Execution(ShortText shortText, StepContext context) {
+ super(context);
+ this.shortText = shortText;
+ }
+
+ @Override
+ protected Void run() throws Exception {
+ getContext()
+ .get(Run.class)
+ .addAction(BadgeAction.createShortText(
+ shortText.getText(),
+ shortText.getColor(),
+ shortText.getBackground(),
+ shortText.getBorderString(),
+ shortText.getBorderColor(),
+ shortText.link));
+ return null;
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddWarningBadgeStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddWarningBadgeStep.java
index b116604..21f7aaf 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddWarningBadgeStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddWarningBadgeStep.java
@@ -1,72 +1,71 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import hudson.Extension;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-
-/**
- * Add an error badge.
- */
-public class AddWarningBadgeStep extends AbstractAddBadgeStep {
-
- /**
- * @param text The text for this warning badge
- */
- @DataBoundConstructor
- public AddWarningBadgeStep(String text) {
- super(null, text);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "addWarningBadge";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Add Warning Badge";
- }
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(getBadge(), getId(), context) {
-
- @Override
- protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
- return BadgeAction.createWarningBadge(badge.getText(), badge.getLink());
- }
- };
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import hudson.Extension;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+
+/**
+ * Add an error badge.
+ */
+public class AddWarningBadgeStep extends AbstractAddBadgeStep {
+
+ /**
+ * @param text The text for this warning badge
+ */
+ @DataBoundConstructor
+ public AddWarningBadgeStep(String text) {
+ super(null, text);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "addWarningBadge";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Add Warning Badge";
+ }
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(getBadge(), getId(), context) {
+
+ @Override
+ protected BadgeAction newBatchAction(Badge badge) throws IllegalArgumentException {
+ return BadgeAction.createWarningBadge(badge.getText(), badge.getLink());
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStep.java
index c108022..e35d89a 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStep.java
@@ -1,122 +1,121 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import hudson.Extension;
-import hudson.model.Run;
-import org.apache.commons.lang.StringUtils;
-import org.jenkinsci.plugins.workflow.steps.StepContext;
-import org.jenkinsci.plugins.workflow.steps.StepExecution;
-import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
-import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.DataBoundSetter;
-
-/**
- * Create a summary text.
- */
-public class CreateSummaryStep extends AbstractStep {
-
- private final String icon;
- private String text;
-
- /**
- * @param icon "The icon for this summary"
- */
- @DataBoundConstructor
- public CreateSummaryStep(String icon) {
- this.icon = icon;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public String getText() {
- return text;
- }
-
- /**
- * @param text "The title text for this summary"
- */
- @DataBoundSetter
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public StepExecution start(StepContext context) {
- return new Execution(icon, text, getId(), context);
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
-
- @Override
- public String getFunctionName() {
- return "createSummary";
- }
-
- @NonNull
- @Override
- public String getDisplayName() {
- return "Create Summary";
- }
-
- }
-
- public static class Execution extends SynchronousStepExecution {
-
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final String icon;
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private transient final String text;
- @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
- private final String id;
-
- Execution(String icon, String text, String id, StepContext context) {
- super(context);
- this.icon = icon;
- this.text = text;
- this.id = id;
- }
-
- @Override
- protected BadgeSummaryAction run() throws Exception {
- BadgeSummaryAction action = new BadgeSummaryAction(icon);
- if (StringUtils.isNotBlank(text)) {
- action.appendText(text);
- }
- action.setId(id);
- getContext().get(Run.class).addAction(action);
- return action;
- }
-
- private static final long serialVersionUID = 1L;
-
- }
-
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import hudson.Extension;
+import hudson.model.Run;
+import org.apache.commons.lang.StringUtils;
+import org.jenkinsci.plugins.workflow.steps.StepContext;
+import org.jenkinsci.plugins.workflow.steps.StepExecution;
+import org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution;
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.kohsuke.stapler.DataBoundSetter;
+
+/**
+ * Create a summary text.
+ */
+public class CreateSummaryStep extends AbstractStep {
+
+ private final String icon;
+ private String text;
+
+ /**
+ * @param icon "The icon for this summary"
+ */
+ @DataBoundConstructor
+ public CreateSummaryStep(String icon) {
+ this.icon = icon;
+ }
+
+ public String getIcon() {
+ return icon;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text "The title text for this summary"
+ */
+ @DataBoundSetter
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public StepExecution start(StepContext context) {
+ return new Execution(icon, text, getId(), context);
+ }
+
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+
+ @Override
+ public String getFunctionName() {
+ return "createSummary";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Create Summary";
+ }
+ }
+
+ public static class Execution extends SynchronousStepExecution {
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient String icon;
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final transient String text;
+
+ @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
+ private final String id;
+
+ Execution(String icon, String text, String id, StepContext context) {
+ super(context);
+ this.icon = icon;
+ this.text = text;
+ this.id = id;
+ }
+
+ @Override
+ protected BadgeSummaryAction run() throws Exception {
+ BadgeSummaryAction action = new BadgeSummaryAction(icon);
+ if (StringUtils.isNotBlank(text)) {
+ action.appendText(text);
+ }
+ action.setId(id);
+ getContext().get(Run.class).addAction(action);
+ return action;
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStep.java
index 32bef34..2dc96e1 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStep.java
@@ -34,30 +34,26 @@
*/
public class RemoveBadgesStep extends AbstractRemoveBadgesStep {
-
- @DataBoundConstructor
- public RemoveBadgesStep() {
- }
-
- @Override
- protected Class extends AbstractBadgeAction> getActionClass() {
- return BadgeAction.class;
- }
-
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+ @DataBoundConstructor
+ public RemoveBadgesStep() {}
@Override
- public String getFunctionName() {
- return "removeBadges";
+ protected Class extends AbstractBadgeAction> getActionClass() {
+ return BadgeAction.class;
}
- @NonNull
- @Override
- public String getDisplayName() {
- return "Remove Badges";
- }
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
- }
+ @Override
+ public String getFunctionName() {
+ return "removeBadges";
+ }
+
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Remove Badges";
+ }
+ }
}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveHtmlBadgesStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveHtmlBadgesStep.java
index cdb02ec..cbd553a 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveHtmlBadgesStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveHtmlBadgesStep.java
@@ -34,31 +34,26 @@
*/
public class RemoveHtmlBadgesStep extends AbstractRemoveBadgesStep {
-
- @DataBoundConstructor
- public RemoveHtmlBadgesStep() {
- }
-
- @Override
- protected Class extends AbstractBadgeAction> getActionClass() {
- return HtmlBadgeAction.class;
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+ @DataBoundConstructor
+ public RemoveHtmlBadgesStep() {}
@Override
- public String getFunctionName() {
- return "removeHtmlBadges";
+ protected Class extends AbstractBadgeAction> getActionClass() {
+ return HtmlBadgeAction.class;
}
- @NonNull
- @Override
- public String getDisplayName() {
- return "Remove Html Badges";
- }
-
- }
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+ @Override
+ public String getFunctionName() {
+ return "removeHtmlBadges";
+ }
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Remove Html Badges";
+ }
+ }
}
diff --git a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStep.java b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStep.java
index af5376a..2c492f7 100644
--- a/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStep.java
+++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStep.java
@@ -34,31 +34,26 @@
*/
public class RemoveSummariesStep extends AbstractRemoveBadgesStep {
-
- @DataBoundConstructor
- public RemoveSummariesStep() {
- }
-
- @Override
- protected Class extends AbstractAction> getActionClass() {
- return BadgeSummaryAction.class;
- }
-
- @Extension
- public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+ @DataBoundConstructor
+ public RemoveSummariesStep() {}
@Override
- public String getFunctionName() {
- return "removeSummaries";
+ protected Class extends AbstractAction> getActionClass() {
+ return BadgeSummaryAction.class;
}
- @NonNull
- @Override
- public String getDisplayName() {
- return "Remove Summaries";
- }
-
- }
+ @Extension
+ public static class DescriptorImpl extends AbstractTaskListenerDescriptor {
+ @Override
+ public String getFunctionName() {
+ return "removeSummaries";
+ }
+ @NonNull
+ @Override
+ public String getDisplayName() {
+ return "Remove Summaries";
+ }
+ }
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
index 2e06e4c..c44ae7c 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
@@ -1,11 +1,11 @@
package com.jenkinsci.plugins.badge.action;
+import static org.junit.jupiter.api.Assertions.*;
+
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-import static org.junit.jupiter.api.Assertions.*;
-
@WithJenkins
class AbstractActionTest {
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
index acaec67..b74e017 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
@@ -1,61 +1,60 @@
package com.jenkinsci.plugins.badge.action;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import hudson.model.Hudson;
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-
@WithJenkins
class BadgeActionTest {
- @Test
- void getIconPath(@SuppressWarnings("unused") JenkinsRule r) {
- assertNull(BadgeAction.getIconPath(null));
- assertEquals("/icon.png", BadgeAction.getIconPath("/icon.png"));
- assertEquals("http://foo.com/icon.png", BadgeAction.getIconPath("http://foo.com/icon.png"));
- assertEquals("https://foo.com/icon.png", BadgeAction.getIconPath("https://foo.com/icon.png"));
-
- assertEquals(Hudson.RESOURCE_PATH + "/images/16x16/http.png", BadgeAction.getIconPath("http.png"));
-
- assertEquals("symbol-information-circle-outline plugin-ionicons-api", BadgeAction.getIconPath("symbol-information-circle-outline plugin-ionicons-api"));
- }
-
- @Test
- void getIconClass(@SuppressWarnings("unused") JenkinsRule r) {
- BadgeAction action = BadgeAction.createBadge("info.gif", "text");
- assertEquals("", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "text");
- assertEquals("icon-sm", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
- assertEquals("icon-sm", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
- assertEquals("icon-sm jenkins-!-color-blue", action.getIconClass());
- action = BadgeAction.createBadge("/foo/symbol-star.gif", "blue", "", null);
- assertEquals("jenkins-!-color-blue", action.getIconClass());
- // teal is not in the palette
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
- assertEquals("icon-sm", action.getIconClass());
- }
-
- @Test
- void getIconColorStyle(@SuppressWarnings("unused") JenkinsRule r) {
- BadgeAction action = BadgeAction.createBadge("info.gif", "text");
- assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
- assertEquals("#000000", action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "var(--yellow)", "", null);
- assertEquals("var(--yellow)", action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "jenkins-!-color-blue", "", null);
- assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
- assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
- assertEquals("teal", action.getIconColorStyle());
- }
-
+ @Test
+ void getIconPath(@SuppressWarnings("unused") JenkinsRule r) {
+ assertNull(BadgeAction.getIconPath(null));
+ assertEquals("/icon.png", BadgeAction.getIconPath("/icon.png"));
+ assertEquals("http://foo.com/icon.png", BadgeAction.getIconPath("http://foo.com/icon.png"));
+ assertEquals("https://foo.com/icon.png", BadgeAction.getIconPath("https://foo.com/icon.png"));
+
+ assertEquals(Hudson.RESOURCE_PATH + "/images/16x16/http.png", BadgeAction.getIconPath("http.png"));
+
+ assertEquals(
+ "symbol-information-circle-outline plugin-ionicons-api",
+ BadgeAction.getIconPath("symbol-information-circle-outline plugin-ionicons-api"));
+ }
+
+ @Test
+ void getIconClass(@SuppressWarnings("unused") JenkinsRule r) {
+ BadgeAction action = BadgeAction.createBadge("info.gif", "text");
+ assertEquals("", action.getIconClass());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "text");
+ assertEquals("icon-sm", action.getIconClass());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
+ assertEquals("icon-sm", action.getIconClass());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
+ assertEquals("icon-sm jenkins-!-color-blue", action.getIconClass());
+ action = BadgeAction.createBadge("/foo/symbol-star.gif", "blue", "", null);
+ assertEquals("jenkins-!-color-blue", action.getIconClass());
+ // teal is not in the palette
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
+ assertEquals("icon-sm", action.getIconClass());
+ }
+
+ @Test
+ void getIconColorStyle(@SuppressWarnings("unused") JenkinsRule r) {
+ BadgeAction action = BadgeAction.createBadge("info.gif", "text");
+ assertNull(action.getIconColorStyle());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
+ assertEquals("#000000", action.getIconColorStyle());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "var(--yellow)", "", null);
+ assertEquals("var(--yellow)", action.getIconColorStyle());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "jenkins-!-color-blue", "", null);
+ assertNull(action.getIconColorStyle());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
+ assertNull(action.getIconColorStyle());
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
+ assertEquals("teal", action.getIconColorStyle());
+ }
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
index d4225cc..67b4240 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
@@ -23,41 +23,39 @@
*/
package com.jenkinsci.plugins.badge.action;
-import hudson.model.Action;
-import hudson.model.BuildBadgeAction;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import hudson.model.Action;
+import hudson.model.BuildBadgeAction;
+import org.junit.jupiter.api.Test;
class ClassHierarchyTest {
- @Test
- void badgeSummaryAction() {
- assertTrue(Action.class.isAssignableFrom(BadgeSummaryAction.class));
- assertTrue(AbstractAction.class.isAssignableFrom(BadgeSummaryAction.class));
-
- assertFalse(BuildBadgeAction.class.isAssignableFrom(BadgeSummaryAction.class));
- assertFalse(AbstractBadgeAction.class.isAssignableFrom(BadgeSummaryAction.class));
- }
-
- @Test
- void badgeAction() {
- assertTrue(Action.class.isAssignableFrom(BadgeAction.class));
- assertTrue(AbstractAction.class.isAssignableFrom(BadgeAction.class));
-
- assertTrue(BuildBadgeAction.class.isAssignableFrom(BadgeAction.class));
- assertTrue(BuildBadgeAction.class.isAssignableFrom(BadgeAction.class));
- }
-
- @Test
- void htmlBadgeAction() {
- assertTrue(Action.class.isAssignableFrom(HtmlBadgeAction.class));
- assertTrue(AbstractAction.class.isAssignableFrom(HtmlBadgeAction.class));
-
- assertTrue(BuildBadgeAction.class.isAssignableFrom(HtmlBadgeAction.class));
- assertTrue(BuildBadgeAction.class.isAssignableFrom(HtmlBadgeAction.class));
- }
-
-}
\ No newline at end of file
+ @Test
+ void badgeSummaryAction() {
+ assertTrue(Action.class.isAssignableFrom(BadgeSummaryAction.class));
+ assertTrue(AbstractAction.class.isAssignableFrom(BadgeSummaryAction.class));
+
+ assertFalse(BuildBadgeAction.class.isAssignableFrom(BadgeSummaryAction.class));
+ assertFalse(AbstractBadgeAction.class.isAssignableFrom(BadgeSummaryAction.class));
+ }
+
+ @Test
+ void badgeAction() {
+ assertTrue(Action.class.isAssignableFrom(BadgeAction.class));
+ assertTrue(AbstractAction.class.isAssignableFrom(BadgeAction.class));
+
+ assertTrue(BuildBadgeAction.class.isAssignableFrom(BadgeAction.class));
+ assertTrue(BuildBadgeAction.class.isAssignableFrom(BadgeAction.class));
+ }
+
+ @Test
+ void htmlBadgeAction() {
+ assertTrue(Action.class.isAssignableFrom(HtmlBadgeAction.class));
+ assertTrue(AbstractAction.class.isAssignableFrom(HtmlBadgeAction.class));
+
+ assertTrue(BuildBadgeAction.class.isAssignableFrom(HtmlBadgeAction.class));
+ assertTrue(BuildBadgeAction.class.isAssignableFrom(HtmlBadgeAction.class));
+ }
+}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
index 8f9c301..a14aca3 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
@@ -25,8 +25,5 @@
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-
@WithJenkins
-abstract class AbstractBadgeTest {
-
-}
+abstract class AbstractBadgeTest {}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
index af868af..7e4e2d4 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
@@ -1,150 +1,149 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import hudson.model.BuildBadgeAction;
-import hudson.model.Result;
-import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.jupiter.api.Test;
-import org.jvnet.hudson.test.JenkinsRule;
-
-import java.util.List;
-import java.util.UUID;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-
-class AddBadgeStepTest extends AbstractBadgeTest {
-
- @Test
- void addBadge(JenkinsRule r) throws Exception {
- addBadge(r, false);
- }
-
- @Test
- void addBadge_in_node(JenkinsRule r) throws Exception {
- addBadge(r, true);
- }
-
- @Test
- void addInfoBadge(JenkinsRule r) throws Exception {
- addStatusBadge(r, "addInfoBadge", "symbol-information-circle plugin-ionicons-api", false);
- addStatusBadge(r,"addInfoBadge", "symbol-information-circle plugin-ionicons-api", true);
- }
-
- @Test
- void addWarningBadge(JenkinsRule r) throws Exception {
- addStatusBadge(r,"addWarningBadge", "symbol-warning plugin-ionicons-api", false);
- addStatusBadge(r,"addWarningBadge", "symbol-warning plugin-ionicons-api", true);
- }
-
- @Test
- void addErrorBadge(JenkinsRule r) throws Exception {
- addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", false);
- addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", true);
- }
-
- @Test
- void addBadge_invalid_link(JenkinsRule r) throws Exception {
- String icon = UUID.randomUUID().toString();
- String text = UUID.randomUUID().toString();
- String link = "javascript:" + UUID.randomUUID();
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addBadge(icon:\"" + icon + "\", text:\"" + text + "\", link:\"" + link + "\")";
- p.setDefinition(new CpsFlowDefinition(script, true));
- r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
- }
-
- @Test
- void addBadge_invalid_text(JenkinsRule r) throws Exception {
- String icon = UUID.randomUUID().toString();
- String textPrefix = UUID.randomUUID().toString();
- String text = textPrefix + "');alert('foo";
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addBadge(icon: '" + icon + "', text:\"" + text + "\")";
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertTrue(action.getIconPath().endsWith(icon));
- assertEquals(textPrefix + "');alert('foo", action.getText());
- }
-
- private void addBadge(JenkinsRule r, boolean inNode) throws Exception {
- String icon = UUID.randomUUID().toString();
- String text = UUID.randomUUID().toString();
- String link = "https://" + UUID.randomUUID();
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addBadge icon: '" + icon + "', text: '" + text + "', link: '" + link + "'";
- if (inNode) {
- script = "node() {" + script + "}";
- }
-
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertTrue(action.getIconPath().endsWith(icon));
- assertEquals(text, action.getText());
- assertEquals(link, action.getLink());
- }
-
- private void addStatusBadge(JenkinsRule r, String functionName, String expectedIcon, boolean withLink) throws Exception {
- String text = UUID.randomUUID().toString();
- String link = "mailto://" + UUID.randomUUID();
-
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, text);
- String script = functionName + " text: '" + text + "'";
- if (withLink) {
- script += ", link: '" + link + "'";
- }
-
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertEquals(text, action.getText());
- assertTrue(action.getIconPath().endsWith(expectedIcon));
- if (withLink) {
- assertEquals(link, action.getLink());
- } else {
- assertNull(action.getLink());
- }
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import hudson.model.BuildBadgeAction;
+import hudson.model.Result;
+import java.util.List;
+import java.util.UUID;
+import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
+import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import org.jenkinsci.plugins.workflow.job.WorkflowRun;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+class AddBadgeStepTest extends AbstractBadgeTest {
+
+ @Test
+ void addBadge(JenkinsRule r) throws Exception {
+ addBadge(r, false);
+ }
+
+ @Test
+ void addBadge_in_node(JenkinsRule r) throws Exception {
+ addBadge(r, true);
+ }
+
+ @Test
+ void addInfoBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r, "addInfoBadge", "symbol-information-circle plugin-ionicons-api", false);
+ addStatusBadge(r, "addInfoBadge", "symbol-information-circle plugin-ionicons-api", true);
+ }
+
+ @Test
+ void addWarningBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r, "addWarningBadge", "symbol-warning plugin-ionicons-api", false);
+ addStatusBadge(r, "addWarningBadge", "symbol-warning plugin-ionicons-api", true);
+ }
+
+ @Test
+ void addErrorBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", false);
+ addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", true);
+ }
+
+ @Test
+ void addBadge_invalid_link(JenkinsRule r) throws Exception {
+ String icon = UUID.randomUUID().toString();
+ String text = UUID.randomUUID().toString();
+ String link = "javascript:" + UUID.randomUUID();
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addBadge(icon:\"" + icon + "\", text:\"" + text + "\", link:\"" + link + "\")";
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
+ }
+
+ @Test
+ void addBadge_invalid_text(JenkinsRule r) throws Exception {
+ String icon = UUID.randomUUID().toString();
+ String textPrefix = UUID.randomUUID().toString();
+ String text = textPrefix + "');alert('foo";
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addBadge(icon: '" + icon + "', text:\"" + text + "\")";
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertTrue(action.getIconPath().endsWith(icon));
+ assertEquals(textPrefix + "');alert('foo", action.getText());
+ }
+
+ private void addBadge(JenkinsRule r, boolean inNode) throws Exception {
+ String icon = UUID.randomUUID().toString();
+ String text = UUID.randomUUID().toString();
+ String link = "https://" + UUID.randomUUID();
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addBadge icon: '" + icon + "', text: '" + text + "', link: '" + link + "'";
+ if (inNode) {
+ script = "node() {" + script + "}";
+ }
+
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertTrue(action.getIconPath().endsWith(icon));
+ assertEquals(text, action.getText());
+ assertEquals(link, action.getLink());
+ }
+
+ private void addStatusBadge(JenkinsRule r, String functionName, String expectedIcon, boolean withLink)
+ throws Exception {
+ String text = UUID.randomUUID().toString();
+ String link = "mailto://" + UUID.randomUUID();
+
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, text);
+ String script = functionName + " text: '" + text + "'";
+ if (withLink) {
+ script += ", link: '" + link + "'";
+ }
+
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertEquals(text, action.getText());
+ assertTrue(action.getIconPath().endsWith(expectedIcon));
+ if (withLink) {
+ assertEquals(link, action.getLink());
+ } else {
+ assertNull(action.getLink());
+ }
+ }
+}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
index a23642b..fdcce66 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
@@ -1,70 +1,68 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.HtmlBadgeAction;
-import hudson.model.BuildBadgeAction;
-import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.jupiter.api.Test;
-import org.jvnet.hudson.test.JenkinsRule;
-
-import java.util.List;
-import java.util.UUID;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-class AddHtmlBadgeStepTest extends AbstractBadgeTest {
-
- @Test
- void addHtmlBadge(JenkinsRule r) throws Exception {
- String html = UUID.randomUUID().toString();
- testAddHtmlBadge(r, html, html);
- }
-
- @Test
- void addHtmlBadge_remove_script(JenkinsRule r) throws Exception {
- String uuid = UUID.randomUUID().toString();
- String html = uuid + "";
- testAddHtmlBadge(r, html, uuid);
- }
-
- private void testAddHtmlBadge(JenkinsRule r, String html, String expected) throws Exception {
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addHtmlBadge(\"" + html + "\")";
-
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- HtmlBadgeAction action = (HtmlBadgeAction) badgeActions.get(0);
- assertEquals(expected, action.getHtml());
- assertEquals(html, action.getRawHtml());
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import com.jenkinsci.plugins.badge.action.HtmlBadgeAction;
+import hudson.model.BuildBadgeAction;
+import java.util.List;
+import java.util.UUID;
+import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
+import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import org.jenkinsci.plugins.workflow.job.WorkflowRun;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+class AddHtmlBadgeStepTest extends AbstractBadgeTest {
+
+ @Test
+ void addHtmlBadge(JenkinsRule r) throws Exception {
+ String html = UUID.randomUUID().toString();
+ testAddHtmlBadge(r, html, html);
+ }
+
+ @Test
+ void addHtmlBadge_remove_script(JenkinsRule r) throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ String html = uuid + "";
+ testAddHtmlBadge(r, html, uuid);
+ }
+
+ private void testAddHtmlBadge(JenkinsRule r, String html, String expected) throws Exception {
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addHtmlBadge(\"" + html + "\")";
+
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ HtmlBadgeAction action = (HtmlBadgeAction) badgeActions.get(0);
+ assertEquals(expected, action.getHtml());
+ assertEquals(html, action.getRawHtml());
+ }
+}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
index f4fe052..da7a689 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
@@ -1,108 +1,107 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
-import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.jupiter.api.Test;
-import org.jvnet.hudson.test.JenkinsRule;
-
-import java.util.List;
-
-import static java.util.UUID.randomUUID;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-
-class CreateSummaryStepTest extends AbstractBadgeTest {
-
- @Test
- void createSummary_plain(JenkinsRule r) throws Exception {
- String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "')");
- assertEquals(text, action.getText());
- }
-
- @Test
- void createSummary_html_unescaped(JenkinsRule r) throws Exception {
- String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary(r, "summary.appendText('', false)");
- assertEquals("", action.getText());
- }
-
- @Test
- void createSummary_html_unescaped_remove_script(JenkinsRule r) throws Exception {
- String text = randomUUID().toString();
- String html = "";
- BadgeSummaryAction action = createSummary(r, "summary.appendText('" + html + "', false);");
- assertEquals("", action.getText());
- assertEquals(html, action.getRawText());
- }
-
- @Test
- void createSummary_html_escaped(JenkinsRule r) throws Exception {
- String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary(r, "summary.appendText('', true)");
- assertEquals("<ul><li>" + text + "</li></ul>", action.getText());
- }
-
- @Test
- void createSummary_all(JenkinsRule r) throws Exception {
- String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "', false, true, true, 'grey')");
- assertEquals("" + text + "", action.getText());
- }
-
- @Test
- void createSummary_with_text(JenkinsRule r) throws Exception {
- String icon = randomUUID().toString();
- String text = randomUUID().toString();
-
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("def summary = createSummary(icon:\"" + icon + "\", text:\"" + text + "\")", true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
- List summaryActions = b.getActions(BadgeSummaryAction.class);
- assertEquals(1, summaryActions.size());
-
- BadgeSummaryAction action = summaryActions.get(0);
- assertTrue(action.getIconPath().endsWith(icon));
- assertEquals(text, action.getText());
- }
-
- private BadgeSummaryAction createSummary(JenkinsRule r, String script) throws Exception {
- String icon = randomUUID().toString();
-
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
- List summaryActions = b.getActions(BadgeSummaryAction.class);
- assertEquals(1, summaryActions.size());
-
- BadgeSummaryAction action = summaryActions.get(0);
- assertTrue(action.getIconPath().endsWith(icon));
- return action;
- }
-}
\ No newline at end of file
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import static java.util.UUID.randomUUID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
+import java.util.List;
+import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
+import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import org.jenkinsci.plugins.workflow.job.WorkflowRun;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+class CreateSummaryStepTest extends AbstractBadgeTest {
+
+ @Test
+ void createSummary_plain(JenkinsRule r) throws Exception {
+ String text = randomUUID().toString();
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "')");
+ assertEquals(text, action.getText());
+ }
+
+ @Test
+ void createSummary_html_unescaped(JenkinsRule r) throws Exception {
+ String text = randomUUID().toString();
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('', false)");
+ assertEquals("", action.getText());
+ }
+
+ @Test
+ void createSummary_html_unescaped_remove_script(JenkinsRule r) throws Exception {
+ String text = randomUUID().toString();
+ String html = "";
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + html + "', false);");
+ assertEquals("", action.getText());
+ assertEquals(html, action.getRawText());
+ }
+
+ @Test
+ void createSummary_html_escaped(JenkinsRule r) throws Exception {
+ String text = randomUUID().toString();
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('', true)");
+ assertEquals("<ul><li>" + text + "</li></ul>", action.getText());
+ }
+
+ @Test
+ void createSummary_all(JenkinsRule r) throws Exception {
+ String text = randomUUID().toString();
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "', false, true, true, 'grey')");
+ assertEquals("" + text + "", action.getText());
+ }
+
+ @Test
+ void createSummary_with_text(JenkinsRule r) throws Exception {
+ String icon = randomUUID().toString();
+ String text = randomUUID().toString();
+
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ p.setDefinition(new CpsFlowDefinition(
+ "def summary = createSummary(icon:\"" + icon + "\", text:\"" + text + "\")", true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+ List summaryActions = b.getActions(BadgeSummaryAction.class);
+ assertEquals(1, summaryActions.size());
+
+ BadgeSummaryAction action = summaryActions.get(0);
+ assertTrue(action.getIconPath().endsWith(icon));
+ assertEquals(text, action.getText());
+ }
+
+ private BadgeSummaryAction createSummary(JenkinsRule r, String script) throws Exception {
+ String icon = randomUUID().toString();
+
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+ List summaryActions = b.getActions(BadgeSummaryAction.class);
+ assertEquals(1, summaryActions.size());
+
+ BadgeSummaryAction action = summaryActions.get(0);
+ assertTrue(action.getIconPath().endsWith(icon));
+ return action;
+ }
+}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
index d026d11..ae3e9d4 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
@@ -1,77 +1,74 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.AbstractBadgeAction;
-import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.jupiter.api.Test;
-import org.jvnet.hudson.test.JenkinsRule;
-
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-class RemoveBadgesStepTest extends AbstractBadgeTest {
-
- @Test
- void removeBadges_by_id(JenkinsRule r) throws Exception {
- removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges(id:'a')", "b");
- }
-
- @Test
- void removeBadges_all(JenkinsRule r) throws Exception {
- removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges()");
- }
-
- @Test
- void removeHtmlBadges_by_id(JenkinsRule r) throws Exception {
- removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges(id:'a')", "b");
- }
-
- @Test
- void removeHtmlBadges_all(JenkinsRule r) throws Exception {
- removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges()");
- }
-
- private void removeBadges(JenkinsRule r, String badgeScriptPrefix, String removeScript, String... remainingBadgeIds) throws Exception {
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- String script = badgeScriptPrefix + ", id: 'a')\n" +
- badgeScriptPrefix + ", id: 'b')\n" +
- removeScript;
-
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getActions(AbstractBadgeAction.class);
-
- assertEquals(remainingBadgeIds.length, badgeActions.size());
-
- for (int i = 0; i < remainingBadgeIds.length; i++) {
- assertEquals(remainingBadgeIds[i], badgeActions.get(i).getId());
- }
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import com.jenkinsci.plugins.badge.action.AbstractBadgeAction;
+import java.util.List;
+import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
+import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import org.jenkinsci.plugins.workflow.job.WorkflowRun;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+class RemoveBadgesStepTest extends AbstractBadgeTest {
+
+ @Test
+ void removeBadges_by_id(JenkinsRule r) throws Exception {
+ removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges(id:'a')", "b");
+ }
+
+ @Test
+ void removeBadges_all(JenkinsRule r) throws Exception {
+ removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges()");
+ }
+
+ @Test
+ void removeHtmlBadges_by_id(JenkinsRule r) throws Exception {
+ removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges(id:'a')", "b");
+ }
+
+ @Test
+ void removeHtmlBadges_all(JenkinsRule r) throws Exception {
+ removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges()");
+ }
+
+ private void removeBadges(JenkinsRule r, String badgeScriptPrefix, String removeScript, String... remainingBadgeIds)
+ throws Exception {
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ String script = badgeScriptPrefix + ", id: 'a')\n" + badgeScriptPrefix + ", id: 'b')\n" + removeScript;
+
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getActions(AbstractBadgeAction.class);
+
+ assertEquals(remainingBadgeIds.length, badgeActions.size());
+
+ for (int i = 0; i < remainingBadgeIds.length; i++) {
+ assertEquals(remainingBadgeIds[i], badgeActions.get(i).getId());
+ }
+ }
+}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
index 1baf6a8..bb26a9a 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
@@ -23,43 +23,44 @@
*/
package com.jenkinsci.plugins.badge.dsl;
+import static java.util.UUID.randomUUID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import com.jenkinsci.plugins.badge.action.BadgeSummaryAction;
+import java.util.List;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
-import java.util.List;
-
-import static java.util.UUID.randomUUID;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
class RemoveSummariesStepTest extends AbstractBadgeTest {
- @Test
- void removeSummaries_by_id(JenkinsRule r) throws Exception {
- removeSummaries(r, "removeSummaries(id:'a')", "b");
- }
+ @Test
+ void removeSummaries_by_id(JenkinsRule r) throws Exception {
+ removeSummaries(r, "removeSummaries(id:'a')", "b");
+ }
- @Test
- void removeSummaries_all(JenkinsRule r) throws Exception {
- removeSummaries(r, "removeSummaries()");
- }
+ @Test
+ void removeSummaries_all(JenkinsRule r) throws Exception {
+ removeSummaries(r, "removeSummaries()");
+ }
- private void removeSummaries(JenkinsRule r, String removeScript, String... remainingBadgeIds) throws Exception {
- String icon = randomUUID().toString();
+ private void removeSummaries(JenkinsRule r, String removeScript, String... remainingBadgeIds) throws Exception {
+ String icon = randomUUID().toString();
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("def summaryA = createSummary(id:'a', icon:\"" + icon + "\")\n"
- + "def summaryB = createSummary(id:'b', icon:\"" + icon + "\")\n"
- + removeScript, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
- List summaryActions = b.getActions(BadgeSummaryAction.class);
- assertEquals(remainingBadgeIds.length, summaryActions.size());
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ p.setDefinition(new CpsFlowDefinition(
+ "def summaryA = createSummary(id:'a', icon:\"" + icon + "\")\n"
+ + "def summaryB = createSummary(id:'b', icon:\"" + icon + "\")\n"
+ + removeScript,
+ true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+ List summaryActions = b.getActions(BadgeSummaryAction.class);
+ assertEquals(remainingBadgeIds.length, summaryActions.size());
- for (int i = 0; i < remainingBadgeIds.length; i++) {
- assertEquals(remainingBadgeIds[i], summaryActions.get(i).getId());
+ for (int i = 0; i < remainingBadgeIds.length; i++) {
+ assertEquals(remainingBadgeIds[i], summaryActions.get(i).getId());
+ }
}
- }
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
index 82cb379..af1a9df 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
@@ -1,91 +1,91 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.jenkinsci.plugins.badge.dsl;
-
-import com.jenkinsci.plugins.badge.action.BadgeAction;
-import hudson.model.BuildBadgeAction;
-import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.jupiter.api.Test;
-import org.jvnet.hudson.test.JenkinsRule;
-
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-
-class ShortTextStepTest extends AbstractBadgeTest {
-
- @Test
- void addShortText(JenkinsRule r) throws Exception {
- String text = UUID.randomUUID().toString();
- String color = UUID.randomUUID().toString();
- String background = UUID.randomUUID().toString();
- Integer border = new Random().nextInt();
- String borderColor = UUID.randomUUID().toString();
- String link = "http://" + UUID.randomUUID();
-
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("addShortText(text:\"" + text + "\",color:\"" + color + "\", background:\"" + background + "\", border:" + border + ", borderColor:\""
- + borderColor + "\", link:\"" + link + "\")", true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertEquals(text, action.getText());
- assertEquals(color, action.getColor());
- assertEquals(background, action.getBackground());
- assertEquals(borderColor, action.getBorderColor());
- assertEquals(border + "px", action.getBorder());
- assertNull(action.getIconPath());
- assertEquals(link, action.getLink());
- }
-
- @Test
- void addShortText_minimal(JenkinsRule r) throws Exception {
- String text = UUID.randomUUID().toString();
-
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("addShortText(text:\"" + text + "\")", true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertEquals(text, action.getText());
- assertNull(action.getColor());
- assertNull(action.getBackground());
- assertNull(action.getBorderColor());
- assertNull(action.getBorder());
- assertNull(action.getIconPath());
- assertNull(action.getLink());
- }
-}
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004-2010, Sun Microsystems, Inc., Serban Iordache
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.jenkinsci.plugins.badge.dsl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import com.jenkinsci.plugins.badge.action.BadgeAction;
+import hudson.model.BuildBadgeAction;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
+import org.jenkinsci.plugins.workflow.job.WorkflowJob;
+import org.jenkinsci.plugins.workflow.job.WorkflowRun;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+class ShortTextStepTest extends AbstractBadgeTest {
+
+ @Test
+ void addShortText(JenkinsRule r) throws Exception {
+ String text = UUID.randomUUID().toString();
+ String color = UUID.randomUUID().toString();
+ String background = UUID.randomUUID().toString();
+ Integer border = new Random().nextInt();
+ String borderColor = UUID.randomUUID().toString();
+ String link = "http://" + UUID.randomUUID();
+
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ p.setDefinition(new CpsFlowDefinition(
+ "addShortText(text:\"" + text + "\",color:\"" + color + "\", background:\"" + background + "\", border:"
+ + border + ", borderColor:\"" + borderColor + "\", link:\"" + link + "\")",
+ true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertEquals(text, action.getText());
+ assertEquals(color, action.getColor());
+ assertEquals(background, action.getBackground());
+ assertEquals(borderColor, action.getBorderColor());
+ assertEquals(border + "px", action.getBorder());
+ assertNull(action.getIconPath());
+ assertEquals(link, action.getLink());
+ }
+
+ @Test
+ void addShortText_minimal(JenkinsRule r) throws Exception {
+ String text = UUID.randomUUID().toString();
+
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+ p.setDefinition(new CpsFlowDefinition("addShortText(text:\"" + text + "\")", true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertEquals(text, action.getText());
+ assertNull(action.getColor());
+ assertNull(action.getBackground());
+ assertNull(action.getBorderColor());
+ assertNull(action.getBorder());
+ assertNull(action.getIconPath());
+ assertNull(action.getLink());
+ }
+}