@Issue("JENKINS-25851") @Test public void buildVariables() throws Exception { j.createFreeStyleProject("ds") .addProperty( new ParametersDefinitionProperty(new StringParameterDefinition("param", "default"))); WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us"); // TODO apparent sandbox bug using buildVariables.param: unclassified field java.util.HashMap // param ScriptApproval.get() .approveSignature( "method java.util.Map get java.lang.Object"); // TODO should be prewhitelisted us.setDefinition( new CpsFlowDefinition( "echo \"build var: ${build(job: 'ds', parameters: [[$class: 'StringParameterValue', name: 'param', value: 'override']]).buildVariables.get('param')}\"", true)); j.assertLogContains("build var: override", j.assertBuildStatusSuccess(us.scheduleBuild2(0))); }
private static void expectRejection( MatrixProject project, String combinationFilter, String signature) throws IOException { ScriptApproval scriptApproval = ScriptApproval.get(); assertEquals(Collections.emptySet(), scriptApproval.getPendingSignatures()); try { project.setCombinationFilter(combinationFilter); } catch (RejectedAccessException x) { assertEquals(Functions.printThrowable(x), signature, x.getSignature()); } Set<ScriptApproval.PendingSignature> pendingSignatures = scriptApproval.getPendingSignatures(); assertEquals(1, pendingSignatures.size()); assertEquals(signature, pendingSignatures.iterator().next().signature); scriptApproval.approveSignature(signature); assertEquals(Collections.emptySet(), scriptApproval.getPendingSignatures()); }