use of org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript in project promoted-builds-plugin by jenkinsci.
the class GroovyConditionTest method testBinding.
@Test
public void testBinding() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
final JobPropertyImpl property = new JobPropertyImpl(p);
final PromotionProcess promotionProcess = property.addProcess("testPromotion");
promotionProcess.conditions.add(new GroovyCondition(new SecureGroovyScript("promotionProcess instanceof hudson.plugins.promoted_builds.PromotionProcess && " + "build instanceof hudson.model.AbstractBuild && " + "jenkins instanceof jenkins.model.Jenkins", false, null), "", ""));
p = j.configRoundtrip(p);
final FreeStyleBuild build = j.buildAndAssertSuccess(p);
Assert.assertNotNull("Promotion was expected", promotionProcess.isMet(build));
}
use of org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript in project promoted-builds-plugin by jenkinsci.
the class GroovyConditionTest method testBooleanScript.
@Test
public void testBooleanScript() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
final JobPropertyImpl property = new JobPropertyImpl(p);
final PromotionProcess promotionProcessTrue = property.addProcess("truePromotion");
promotionProcessTrue.conditions.add(new GroovyCondition(new SecureGroovyScript("true", false, null), "", ""));
final PromotionProcess promotionProcessFalse = property.addProcess("falsePromotion");
promotionProcessFalse.conditions.add(new GroovyCondition(new SecureGroovyScript("false", false, null), "", ""));
p = j.configRoundtrip(p);
final FreeStyleBuild build = j.buildAndAssertSuccess(p);
Assert.assertNotNull("Promotion was expected", promotionProcessTrue.isMet(build));
Assert.assertNull("Promotion was not expected", promotionProcessFalse.isMet(build));
}
use of org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript in project promoted-builds-plugin by jenkinsci.
the class GroovyConditionTest method testMapScript.
@Test
public void testMapScript() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
final JobPropertyImpl property = new JobPropertyImpl(p);
final PromotionProcess promotionProcessEmptyMap = property.addProcess("emptyMap");
promotionProcessEmptyMap.conditions.add(new GroovyCondition(new SecureGroovyScript("[:]", false, null), "", ""));
final PromotionProcess promotionProcessNonEmptyMap = property.addProcess("nonEmptyMap");
promotionProcessNonEmptyMap.conditions.add(new GroovyCondition(new SecureGroovyScript("[foo: 'bar']", false, null), "", ""));
p = j.configRoundtrip(p);
final FreeStyleBuild build = j.buildAndAssertSuccess(p);
Assert.assertNull("Promotion was not expected", promotionProcessEmptyMap.isMet(build));
Assert.assertNotNull("Promotion was expected", promotionProcessNonEmptyMap.isMet(build));
}
Aggregations