)); WorkflowRun run = r.buildAndAssertSuccess(job); LinearScanner scan = new LinearScanner(); FlowNode node = scan.findFirstMatch(run.getExecution(), new DescriptorMatchPredicate(StateMetaStep.DescriptorImpl.class)); Assert.assertNotNull(node);
LinearScanner scan = new LinearScanner();
@Test public void testReallyUnusualStepInstantiations() throws Exception { WorkflowJob job = r.jenkins.createProject(WorkflowJob.class, "unusualInstantiation"); job.setDefinition(new CpsFlowDefinition( " node() {\n" + " writeFile text: 'hello world', file: 'msg.out'\n" + " step(new hudson.tasks.ArtifactArchiver('msg.out'))\n" + // note, not whitelisted "}", false)); WorkflowRun run = r.buildAndAssertSuccess(job); LinearScanner scan = new LinearScanner(); FlowNode testNode = scan.findFirstMatch(run.getExecution().getCurrentHeads().get(0), new NodeStepTypePredicate("step")); ArgumentsAction act = testNode.getPersistentAction(ArgumentsAction.class); Assert.assertNotNull(act); Object delegate = act.getArgumentValue("delegate"); // Test that for a raw Describable we explode it into its arguments Map Assert.assertThat(delegate, instanceOf(UninstantiatedDescribable.class)); UninstantiatedDescribable ud = (UninstantiatedDescribable)delegate; Map<String, ?> args = (Map<String,?>)(((UninstantiatedDescribable)delegate).getArguments()); Assert.assertThat(args, IsMapContaining.hasEntry("artifacts", "msg.out")); Assert.assertEquals(ArtifactArchiver.class.getName(), ud.getModel().getType().getName()); } }
)); WorkflowRun run = r.buildAndAssertSuccess(job); LinearScanner scan = new LinearScanner();
/** * Tests the ability to execute a step with an unnamed monomorphic describable argument. */ @Issue("JENKINS-29711") @Test public void monomorphic() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "mon"); p.setDefinition(new CpsFlowDefinition("monomorphStep([firstArg:'one', secondArg:'two'])", true)); r.assertLogContains("First arg: one, second arg: two", r.assertBuildStatusSuccess(p.scheduleBuild2(0))); WorkflowRun run = p.getLastBuild(); LinearScanner scanner = new LinearScanner(); FlowNode node = scanner.findFirstMatch(run.getExecution().getCurrentHeads(), new NodeStepTypePredicate("monomorphStep")); ArgumentsAction argumentsAction = node.getPersistentAction(ArgumentsAction.class); Assert.assertNotNull(argumentsAction); Assert.assertEquals("one,two", ArgumentsAction.getStepArgumentsAsString(node)); }
@Test @Issue("JENKINS-48644") public void testMissingDescriptionInsideStage() throws Exception { Assume.assumeTrue(r.jenkins.getComputer("").isUnix()); // No need for windows-specific testing WorkflowJob j = r.jenkins.createProject(WorkflowJob.class, "HiddenStep"); j.setDefinition(new CpsFlowDefinition("node{\n" + " stage ('Build') {\n" + " sh \"echo 'Building'\"\n" + " }\n" + " stage ('Test') {\n" + " sh \"echo 'testing'\"\n" + " }\n" + " stage ('Deploy') {\n" + " sh \"echo 'deploy'\"\n" + " }\n" + "}\n", true)); WorkflowRun run = r.buildAndAssertSuccess(j); List<FlowNode> nodes = new LinearScanner().filteredNodes(run.getExecution(), new NodeStepTypePredicate("sh")); for (FlowNode f : nodes) { if (ArgumentsAction.getStepArgumentsAsString(f) == null) { Assert.fail("No arguments action for node: "+f.toString()); } } }