use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class LDAPSecurityRealmTest method configure_securityRealm.
@Test
@ConfiguredWithCode("LDAPSecurityRealmTest.yml")
public void configure_securityRealm() {
final Jenkins jenkins = Jenkins.getInstance();
final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
assertEquals(1, securityRealm.getConfigurations().size());
assertTrue(securityRealm.getUserIdStrategy() instanceof IdStrategy.CaseInsensitive);
assertTrue(securityRealm.getGroupIdStrategy() instanceof IdStrategy.CaseSensitive);
final LDAPConfiguration configuration = securityRealm.getConfigurations().get(0);
assertEquals("ldap.acme.com", configuration.getServer());
assertEquals("SECRET", configuration.getManagerPassword());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class MailerTest method configure_mailer.
@Test
@ConfiguredWithCode("MailerTest.yml")
public void configure_mailer() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
final Mailer.DescriptorImpl descriptor = (Mailer.DescriptorImpl) jenkins.getDescriptor(Mailer.class);
assertEquals("4441", descriptor.getSmtpPort());
assertEquals("do-not-reply@acme.org", descriptor.getReplyToAddress());
// FIXME setAdminAddress is deprecated and should NOT be set this way
// see https://github.com/jenkinsci/mailer-plugin/pull/39
assertEquals("admin@acme.org", descriptor.getAdminAddress());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class RootElementConfigurator method all.
static List<RootElementConfigurator> all() {
List<RootElementConfigurator> configurators = new ArrayList<>();
final Jenkins jenkins = Jenkins.getInstance();
configurators.addAll(jenkins.getExtensionList(RootElementConfigurator.class));
for (GlobalConfigurationCategory category : GlobalConfigurationCategory.all()) {
configurators.add(new GlobalConfigurationCategoryConfigurator(category));
}
return configurators;
}
use of jenkins.model.Jenkins in project workflow-job-plugin by jenkinsci.
the class WorkflowRun method sleep.
private AsynchronousExecution sleep() {
final AsynchronousExecution asynchronousExecution = new AsynchronousExecution() {
@Override
public void interrupt(boolean forShutdown) {
if (forShutdown) {
return;
}
Timer.get().submit(new Runnable() {
@Override
public void run() {
if (execution == null) {
return;
}
Executor executor = getExecutor();
if (executor == null) {
LOGGER.log(Level.WARNING, "Lost executor for {0}", WorkflowRun.this);
return;
}
try {
Collection<CauseOfInterruption> causes = executor.getCausesOfInterruption();
execution.interrupt(executor.abortResult(), causes.toArray(new CauseOfInterruption[causes.size()]));
} catch (Exception x) {
LOGGER.log(Level.WARNING, null, x);
}
executor.recordCauseOfInterruption(WorkflowRun.this, listener);
printLater(StopState.TERM, "Click here to forcibly terminate running steps");
}
});
}
@Override
public boolean blocksRestart() {
return execution != null && execution.blocksRestart();
}
@Override
public boolean displayCell() {
return blocksRestart();
}
};
final AtomicReference<ScheduledFuture<?>> copyLogsTask = new AtomicReference<>();
copyLogsTask.set(copyLogsExecutorService().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
synchronized (completed) {
if (completed.get()) {
asynchronousExecution.completed(null);
copyLogsTask.get().cancel(false);
return;
}
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null || jenkins.isTerminating()) {
LOGGER.log(Level.FINE, "shutting down, breaking waitForCompletion on {0}", this);
// Stop writing content, in case a new set of objects gets loaded after in-VM restart and starts writing to the same file:
listener.closeQuietly();
listener = new StreamBuildListener(new NullStream());
return;
}
try (WithThreadName naming = new WithThreadName(" (" + WorkflowRun.this + ")")) {
copyLogs();
}
}
}
}, 1, 1, TimeUnit.SECONDS));
return asynchronousExecution;
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class JenkinsLogs method addOtherMasterLogs.
/**
* Grabs any files that look like log files directly under {@code $JENKINS_HOME}, just in case
* any of them are useful.
* Does not add anything if Jenkins instance is unavailable.
* Some plugins write log files here.
*/
private void addOtherMasterLogs(Container result) {
final Jenkins jenkins = Jenkins.getInstance();
File[] files = jenkins.getRootDir().listFiles(ROTATED_LOGFILE_FILTER);
if (files != null) {
for (File f : files) {
result.add(new FileContent("other-logs/" + f.getName(), f));
}
}
File logs = getLogsRoot();
files = logs.listFiles(ROTATED_LOGFILE_FILTER);
if (files != null) {
for (File f : files) {
result.add(new FileContent("other-logs/" + f.getName(), f));
}
}
File taskLogs = new File(logs, "tasks");
files = taskLogs.listFiles(ROTATED_LOGFILE_FILTER);
if (files != null) {
for (File f : files) {
result.add(new FileContent("other-logs/" + f.getName(), f));
}
}
}
Aggregations