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 ad72a958..1049fb92 100644 --- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java +++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java @@ -35,11 +35,11 @@ public abstract class AbstractAddBadgeStep extends Step { private final String id; - private final String icon; - private final String text; - private final String cssClass; - private final String style; - private final String link; + private String icon; + private String text; + private String cssClass; + private String style; + private String link; protected AbstractAddBadgeStep(String id, String icon, String text, String cssClass, String style, String link) { this.id = id; @@ -58,22 +58,42 @@ protected String getIcon() { return icon; } + protected void setIcon(String icon) { + this.icon = icon; + } + protected String getText() { return text; } + protected void setText(String text) { + this.text = text; + } + protected String getCssClass() { return cssClass; } + protected void setCssClass(String cssClass) { + this.cssClass = cssClass; + } + protected String getStyle() { return style; } + protected void setStyle(String style) { + this.style = style; + } + protected String getLink() { return link; } + protected void setLink(String link) { + this.link = link; + } + abstract static class Execution extends SynchronousStepExecution { private static final long serialVersionUID = 1L; 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 d867e715..54604b88 100644 --- a/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java +++ b/src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java @@ -26,9 +26,11 @@ import com.jenkinsci.plugins.badge.action.BadgeAction; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; +import org.apache.commons.lang.StringUtils; 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. @@ -40,6 +42,16 @@ public AddBadgeStep(String id, String icon, String text, String cssClass, String super(id, icon, text, cssClass, style, link); } + /** + * @deprecated replaced by {@link #setStyle(String)}. + */ + @DataBoundSetter + @Deprecated(since = "2.0", forRemoval = true) + public void setColor(String color) { + // translate old color to new field + setStyle("color: " + color + ";" + StringUtils.defaultString(getStyle())); + } + @Override public StepExecution start(StepContext context) { return new Execution(getId(), getIcon(), getText(), getCssClass(), getStyle(), getLink(), context) {