Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-55595] Configuration as code support #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/main/java/hudson/plugins/s3/S3BucketPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

Expand Down Expand Up @@ -391,7 +392,7 @@ public BuildStepMonitor getRequiredMonitorService() {
@Symbol("s3Upload")
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {

private final CopyOnWriteList<S3Profile> profiles = new CopyOnWriteList<S3Profile>();
private List<S3Profile> profiles = new ArrayList<S3Profile>();
public static final Level[] consoleLogLevels = { Level.INFO, Level.WARNING, Level.SEVERE };
private static final Logger LOGGER = Logger.getLogger(DescriptorImpl.class.getName());
private static final Result[] pluginFailureResultConstraints = { Result.FAILURE, Result.UNSTABLE, Result.SUCCESS };
Expand All @@ -409,6 +410,11 @@ public DescriptorImpl() {
this(S3BucketPublisher.class);
}

@DataBoundSetter
public void setProfiles(List<S3Profile> profiles) {
this.profiles = profiles;
}

@Override
public String getDisplayName() {
return "Publish artifacts to S3 Bucket";
Expand All @@ -423,9 +429,9 @@ public String getHelpFile() {
public boolean configure(StaplerRequest req, JSONObject json) {
final JSONArray array = json.optJSONArray("profile");
if (array != null) {
profiles.replaceBy(req.bindJSONToList(S3Profile.class, array));
profiles = new ArrayList<>(req.bindJSONToList(S3Profile.class, array));
} else {
profiles.replaceBy(req.bindJSON(S3Profile.class, json.getJSONObject("profile")));
profiles = new ArrayList<>(Arrays.asList(req.bindJSON(S3Profile.class, json.getJSONObject("profile"))));
}
save();
return true;
Expand Down Expand Up @@ -459,7 +465,7 @@ public ListBoxModel doFillPluginFailureResultConstraintItems() {

@SuppressWarnings("unused")
public void replaceProfiles(List<S3Profile> profiles) {
this.profiles.replaceBy(profiles);
this.profiles = new ArrayList<>(profiles);
save();
}

Expand Down