Search in sources :

Example 41 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.

the class CFNDescribeStackTests method describe.

@Test
public void describe() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    Mockito.when(this.stack.describeOutputs()).thenReturn(Collections.singletonMap("foo", "bar"));
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  def outputs = cfnDescribe(stack: 'foo')\n" + "  echo \"foo=${outputs['foo']}\"" + "}\n", true));
    Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    this.jenkinsRule.assertLogContains("foo=bar", run);
    PowerMockito.verifyNew(CloudFormationStack.class).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) TaskListener(hudson.model.TaskListener) Run(hudson.model.Run) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 42 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.

the class CFNExecuteChangeSetTests method executeChangeSet.

@Test
public void executeChangeSet() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  cfnExecuteChangeSet(stack: 'foo', changeSet: 'bar')" + "}\n", true));
    this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
    Mockito.verify(this.stack).executeChangeSet(Mockito.eq("bar"), Mockito.anyLong());
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) TaskListener(hudson.model.TaskListener) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 43 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.

the class CFNValidateStepTests method validateWithUrlSuccess.

@Test
public void validateWithUrlSuccess() throws Exception {
    WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    job.setDefinition(new CpsFlowDefinition("" + "node {\n" + "  cfnValidate(url: 'foo')" + "}\n", true));
    this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    ArgumentCaptor<ValidateTemplateRequest> captor = ArgumentCaptor.forClass(ValidateTemplateRequest.class);
    Mockito.verify(this.cloudFormation).validateTemplate(captor.capture());
    Assertions.assertThat(captor.getValue()).isEqualTo(new ValidateTemplateRequest().withTemplateURL("foo"));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) ValidateTemplateRequest(com.amazonaws.services.cloudformation.model.ValidateTemplateRequest) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 44 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary_with_text.

@Test
public void createSummary_with_text() throws Exception {
    String icon = randomUUID().toString();
    String text = randomUUID().toString();
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition("def summary = createSummary(icon:\"" + icon + "\", text:\"" + text + "\")", true));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List<BadgeSummaryAction> summaryActions = b.getActions(BadgeSummaryAction.class);
    assertEquals(1, summaryActions.size());
    BadgeSummaryAction action = summaryActions.get(0);
    assertTrue(action.getIconPath().endsWith(icon));
    assertEquals(text, action.getText());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction) Test(org.junit.Test)

Example 45 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary.

private BadgeSummaryAction createSummary(String script) throws Exception {
    String icon = randomUUID().toString();
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List<BadgeSummaryAction> summaryActions = b.getActions(BadgeSummaryAction.class);
    assertEquals(1, summaryActions.size());
    BadgeSummaryAction action = summaryActions.get(0);
    assertTrue(action.getIconPath().endsWith(icon));
    return action;
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction)

Aggregations

CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)206 Test (org.junit.Test)196 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)168 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)111 Issue (org.jvnet.hudson.test.Issue)63 Map (java.util.Map)60 List (java.util.List)26 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 RunList (hudson.util.RunList)20 ExtensionList (hudson.ExtensionList)19 Statement (org.junit.runners.model.Statement)19 Run (hudson.model.Run)17 URL (java.net.URL)16 AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)12 TaskListener (hudson.model.TaskListener)11 CpsFlowExecution (org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)10 NodeStepTypePredicate (org.jenkinsci.plugins.workflow.graphanalysis.NodeStepTypePredicate)9 DescribeChangeSetResult (com.amazonaws.services.cloudformation.model.DescribeChangeSetResult)7 Parameter (com.amazonaws.services.cloudformation.model.Parameter)6