use of jenkins.model.Jenkins in project workflow-cps-plugin by jenkinsci.
the class FlowDurabilityTest method testDurableAgainstCleanRestartSurvivesIt.
/**
* Verifies that if we're only durable against clean restarts, the pipeline will survive it.
*/
@Test
public void testDurableAgainstCleanRestartSurvivesIt() throws Exception {
final String jobName = "durableAgainstClean";
final String[] logStart = new String[1];
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
Jenkins jenkins = story.j.jenkins;
WorkflowRun run = createAndRunSleeperJob(story.j.jenkins, jobName, FlowDurabilityHint.PERFORMANCE_OPTIMIZED);
FlowExecution exec = run.getExecution();
assertBaseStorageType(exec, BulkFlowNodeStorage.class);
logStart[0] = JenkinsRule.getLog(run);
}
});
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowRun run = story.j.jenkins.getItemByFullName(jobName, WorkflowJob.class).getLastBuild();
Assert.assertEquals(FlowDurabilityHint.PERFORMANCE_OPTIMIZED, run.getExecution().getDurabilityHint());
assertBaseStorageType(run.getExecution(), BulkFlowNodeStorage.class);
verifySafelyResumed(story.j, run, true, logStart[0]);
}
});
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class Configurator method lookupForBaseType.
/**
* Finds a Configurator for base type and a short name
* @param clazz Base class
* @param shortname Short name of the implementation
* @return Configurator
*/
@CheckForNull
public static Configurator lookupForBaseType(Class<?> clazz, @Nonnull String shortname) {
final Jenkins jenkins = Jenkins.getInstance();
final ExtensionList<Configurator> l = jenkins.getExtensionList(Configurator.class);
for (Configurator c : l) {
if (shortname.equalsIgnoreCase(c.getName())) {
// short name match, ensure that the type is compliant
if (clazz.isAssignableFrom(c.getTarget())) {
// Implements child class
return c;
}
}
}
return null;
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfigurator method configure.
@Override
public Jenkins configure(Object c) throws Exception {
Map config = (Map) c;
Jenkins jenkins = Jenkins.getInstance();
configure(config, jenkins);
return jenkins;
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class AdminWhitelistRuleConfiguratorTest method checkM2SSecurityKillSwitch_enabled.
@Test
@Issue("Issue #28")
@ConfiguredWithCode("AdminWhitelistRuleConfigurator/Slave2MasterSecurityKillSwitch_enabled.yml")
public void checkM2SSecurityKillSwitch_enabled() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
AdminWhitelistRule rule = jenkins.getInjector().getInstance(AdminWhitelistRule.class);
Assert.assertTrue("MasterToSlave Security should be enabled", rule.getMasterKillSwitch());
}
use of jenkins.model.Jenkins in project configuration-as-code-plugin by jenkinsci.
the class HudsonPrivateSecurityRealmConfiguratorTest method configure_local_security_and_admin_user.
@Test
@ConfiguredWithCode("HudsonPrivateSecurityRealmConfiguratorTest.yml")
public void configure_local_security_and_admin_user() throws Exception {
final Jenkins jenkins = Jenkins.getInstance();
final HudsonPrivateSecurityRealm securityRealm = (HudsonPrivateSecurityRealm) jenkins.getSecurityRealm();
assertFalse(securityRealm.allowsSignup());
final User admin = User.getById("admin", false);
assertNotNull(admin);
final HudsonPrivateSecurityRealm.Details details = admin.getProperty(HudsonPrivateSecurityRealm.Details.class);
assertTrue(details.isPasswordCorrect("1234"));
final FullControlOnceLoggedInAuthorizationStrategy authorizationStrategy = (FullControlOnceLoggedInAuthorizationStrategy) jenkins.getAuthorizationStrategy();
assertTrue(authorizationStrategy.isAllowAnonymousRead());
}
Aggregations