use of hudson.BulkChange in project workflow-job-plugin by jenkinsci.
the class WorkflowJob method setTriggers.
public void setTriggers(List<Trigger<?>> inputTriggers) throws IOException {
triggers = null;
BulkChange bc = new BulkChange(this);
try {
PipelineTriggersJobProperty originalProp = getTriggersJobProperty();
removeProperty(PipelineTriggersJobProperty.class);
PipelineTriggersJobProperty triggerProp = new PipelineTriggersJobProperty(null);
triggerProp.setTriggers(inputTriggers);
addProperty(triggerProp);
bc.commit();
originalProp.stopTriggers();
// No longer need to start triggers here - that's done by when we add the property.
} finally {
bc.abort();
}
}
use of hudson.BulkChange in project jenkins by jenkinsci.
the class GlobalSecurityConfiguration method doConfigure.
@POST
public synchronized void doConfigure(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
// for compatibility reasons, the actual value is stored in Jenkins
BulkChange bc = new BulkChange(Jenkins.get());
try {
boolean result = configure(req, req.getSubmittedForm());
LOGGER.log(Level.FINE, "security saved: " + result);
Jenkins.get().save();
FormApply.success(req.getContextPath() + "/manage").generateResponse(req, rsp, null);
} finally {
bc.commit();
}
}
use of hudson.BulkChange in project jenkins by jenkinsci.
the class Jenkins method setViews.
/**
* Completely replaces views.
*
* <p>
* This operation is NOT provided as an atomic operation, but rather
* the sole purpose of this is to define a setter for this to help
* introspecting code, such as system-config-dsl plugin
*/
// even if we want to offer this atomic operation, CopyOnWriteArrayList
// offers no such operation
public void setViews(Collection<View> views) throws IOException {
try (BulkChange bc = new BulkChange(this)) {
this.views.clear();
for (View v : views) {
addView(v);
}
bc.commit();
}
}
use of hudson.BulkChange in project jenkins by jenkinsci.
the class Jenkins method doConfigExecutorsSubmit.
/**
* Accepts submission from the node configuration page.
*/
@POST
public synchronized void doConfigExecutorsSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
checkPermission(ADMINISTER);
try (BulkChange bc = new BulkChange(this)) {
JSONObject json = req.getSubmittedForm();
ExtensionList.lookupSingleton(MasterBuildConfiguration.class).configure(req, json);
getNodeProperties().rebuild(req, json.optJSONObject("nodeProperties"), NodeProperty.all());
bc.commit();
}
updateComputerList();
// back to the computer page
rsp.sendRedirect(req.getContextPath() + '/' + toComputer().getUrl());
}
use of hudson.BulkChange in project jenkins by jenkinsci.
the class NodeProvisionerTest method baselineSlaveUsage.
/**
* Scenario: make sure we take advantage of statically configured agents.
*/
// TODO fragile
@Test
public void baselineSlaveUsage() throws Exception {
assumeFalse("TODO: Windows container agents do not have enough resources to run this test", Functions.isWindows() && System.getenv("CI") != null);
try (BulkChange bc = new BulkChange(r.jenkins)) {
DummyCloudImpl cloud = initHudson(0);
// add agents statically upfront
r.createSlave().toComputer().connect(false).get();
r.createSlave().toComputer().connect(false).get();
verifySuccessfulCompletion(buildAll(create5SlowJobs(new Latch(5))));
// we should have used two static slaves, thus only 3 slaves should have been provisioned
assertEquals(3, cloud.numProvisioned);
}
}
Aggregations