Skip to content

Commit

Permalink
Keep color field backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
strangelookingnerd committed May 19, 2024
1 parent 76a89a1 commit 2669f85
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,22 +58,42 @@ protected String getIcon() {
return icon;
}

protected void setIcon(String icon) {
this.icon = icon;

Check warning on line 62 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java#L62

Added line #L62 was not covered by tests
}

protected String getText() {
return text;
}

protected void setText(String text) {
this.text = text;

Check warning on line 70 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java#L70

Added line #L70 was not covered by tests
}

Check warning on line 71 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 62-71 are not covered by tests

protected String getCssClass() {
return cssClass;
}

protected void setCssClass(String cssClass) {
this.cssClass = cssClass;
}

Check warning on line 79 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 78-79 are not covered by tests

Check warning on line 79 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java#L78-L79

Added lines #L78 - L79 were not covered by tests

protected String getStyle() {
return style;
}

protected void setStyle(String style) {
this.style = style;
}

Check warning on line 87 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 86-87 are not covered by tests

Check warning on line 87 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java#L86-L87

Added lines #L86 - L87 were not covered by tests

protected String getLink() {
return link;
}

protected void setLink(String link) {
this.link = link;

Check warning on line 94 in src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AbstractAddBadgeStep.java#L94

Added line #L94 was not covered by tests
}

abstract static class Execution extends SynchronousStepExecution<AbstractBadgeAction> {

private static final long serialVersionUID = 1L;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()));

Check warning on line 52 in src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 52 is not covered by tests

Check warning on line 52 in src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStep.java#L52

Added line #L52 was not covered by tests
}

@Override
public StepExecution start(StepContext context) {
return new Execution(getId(), getIcon(), getText(), getCssClass(), getStyle(), getLink(), context) {
Expand Down

0 comments on commit 2669f85

Please sign in to comment.