use of hudson.BulkChange in project kubernetes-plugin by jenkinsci.
the class PodTemplateAction method pop.
@Deprecated
public String pop() throws IOException {
if (run == null) {
LOGGER.warning("run is null, cannot pop");
return null;
}
synchronized (run) {
BulkChange bc = new BulkChange(run);
try {
PodTemplateAction action = run.getAction(PodTemplateAction.class);
if (action == null) {
action = new PodTemplateAction(run);
run.addAction(action);
}
String template = action.stack.pop();
bc.commit();
return template;
} finally {
bc.abort();
}
}
}
use of hudson.BulkChange in project hudson-2.x by hudson.
the class Hudson method doConfigExecutorsSubmit.
/**
* Accepts submission from the configuration page.
*/
public synchronized void doConfigExecutorsSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(ADMINISTER);
BulkChange bc = new BulkChange(this);
try {
JSONObject json = req.getSubmittedForm();
setNumExecutors(Integer.parseInt(req.getParameter("numExecutors")));
if (req.hasParameter("master.mode")) {
mode = Mode.valueOf(req.getParameter("master.mode"));
} else {
mode = Mode.NORMAL;
}
setNodes(req.bindJSONToList(Slave.class, json.get("slaves")));
} finally {
bc.commit();
}
// go to the top page
rsp.sendRedirect(req.getContextPath() + '/');
}
use of hudson.BulkChange in project hudson-2.x by hudson.
the class ComputerSet method doConfigSubmit.
/**
* Accepts submission from the configuration page.
*/
public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
BulkChange bc = new BulkChange(MONITORS_OWNER);
try {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
monitors.rebuild(req, req.getSubmittedForm(), getNodeMonitorDescriptors());
// add in the rest of instances are ignored instances
for (Descriptor<NodeMonitor> d : NodeMonitor.all()) if (monitors.get(d) == null) {
NodeMonitor i = createDefaultInstance(d, true);
if (i != null)
monitors.add(i);
}
rsp.sendRedirect2(".");
} finally {
bc.commit();
}
}
use of hudson.BulkChange in project support-core-plugin by jenkinsci.
the class SupportAutomatedBundleConfiguration method configure.
@Override
@POST
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
if (json.getBoolean("enabled") && !json.has("components")) {
throw new Descriptor.FormException(Messages.SupportAutomatedBundleConfiguration_enabled_noComponents(), "components");
}
try (BulkChange bc = new BulkChange(this)) {
setComponentIds(parseRequest(req, json));
setPeriod(json.getInt("period"));
setEnabled(json.getBoolean("enabled"));
bc.commit();
} catch (IOException e) {
LOG.log(WARNING, "Failed to save " + getConfigFile(), e);
}
return true;
}
use of hudson.BulkChange in project workflow-job-plugin by jenkinsci.
the class WorkflowJob method addTrigger.
public void addTrigger(Trigger trigger) throws IOException {
BulkChange bc = new BulkChange(this);
try {
PipelineTriggersJobProperty originalProp = getTriggersJobProperty();
Trigger old = originalProp.getTriggerForDescriptor(trigger.getDescriptor());
if (old != null) {
originalProp.removeTrigger(old);
old.stop();
}
originalProp.addTrigger(trigger);
removeProperty(PipelineTriggersJobProperty.class);
addProperty(originalProp);
bc.commit();
} finally {
bc.abort();
}
}
Aggregations