use of hudson.BulkChange in project support-core-plugin by jenkinsci.
the class InetAddressContentFilterTest method shouldFilterInetAddresses.
@Issue("JENKINS-21670")
@Test
public void shouldFilterInetAddresses() {
InetAddressContentFilter filter = InetAddressContentFilter.get();
// speed up test execution by ignoring new content mappings
ContentMappings mappings = ContentMappings.get();
try (BulkChange ignored = new BulkChange(mappings)) {
qt().forAll(inetAddress()).checkAssert(address -> assertThat(ContentFilter.filter(filter, address)).contains("ip_").doesNotContain(address));
}
}
use of hudson.BulkChange in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method notifyListeners.
void notifyListeners(List<FlowNode> nodes, boolean synchronous) {
List<GraphListener> toRun = getListenersToRun();
if (!toRun.isEmpty()) {
Saveable s = Saveable.NOOP;
try {
Queue.Executable exec = owner.getExecutable();
if (exec instanceof Saveable) {
s = (Saveable) exec;
}
} catch (IOException x) {
LOGGER.log(Level.WARNING, "failed to notify listeners of changes to " + nodes + " in " + this, x);
}
BulkChange bc = new BulkChange(s);
try {
for (FlowNode node : nodes) {
for (GraphListener listener : toRun) {
if (listener instanceof GraphListener.Synchronous == synchronous) {
try {
listener.onNewHead(node);
} catch (Throwable x) {
LOGGER.log(Level.WARNING, null, x);
}
}
}
}
} finally {
if (synchronous) {
// hack to skip save—we are holding a lock
bc.abort();
} else {
try {
bc.commit();
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, x);
}
}
}
}
}
use of hudson.BulkChange in project configuration-as-code-plugin by jenkinsci.
the class BaseConfigurator method configure.
@NonNull
@Override
public T configure(CNode c, ConfigurationContext context) throws ConfiguratorException {
final Mapping mapping = (c != null ? c.asMapping() : Mapping.EMPTY);
final T instance = instance(mapping, context);
if (instance instanceof Saveable) {
try (BulkChange bc = new BulkChange((Saveable) instance)) {
configure(mapping, instance, false, context);
bc.commit();
} catch (IOException e) {
throw new ConfiguratorException("Failed to save " + instance, e);
}
} else {
configure(mapping, instance, false, context);
}
return instance;
}
use of hudson.BulkChange in project workflow-job-plugin by jenkinsci.
the class WorkflowJob method setConcurrentBuild.
public void setConcurrentBuild(boolean b) throws IOException {
concurrentBuild = null;
boolean propertyExists = getProperty(DisableConcurrentBuildsJobProperty.class) != null;
// does not exist, we need to add the property. Yay for flipping boolean values around!
if (propertyExists == b) {
BulkChange bc = new BulkChange(this);
try {
removeProperty(DisableConcurrentBuildsJobProperty.class);
if (!b) {
addProperty(new DisableConcurrentBuildsJobProperty());
}
bc.commit();
} finally {
bc.abort();
}
}
}
use of hudson.BulkChange in project workflow-job-plugin by jenkinsci.
the class WorkflowJob method setResumeBlocked.
@Override
public void setResumeBlocked(boolean resumeBlocked) {
try {
boolean previousState = isResumeBlocked();
if (resumeBlocked != previousState) {
BulkChange bc = new BulkChange(this);
try {
removeProperty(DisableResumeJobProperty.class);
if (resumeBlocked) {
addProperty(new DisableResumeJobProperty());
}
bc.commit();
} finally {
bc.abort();
}
}
} catch (IOException ioe) {
LOGGER.log(Level.WARNING, "Error persisting resume property statue", ioe);
}
}
Aggregations