use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackFailure.
@Test
public void createChangeSetStackFailure() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(stack.exists()).thenReturn(true);
Mockito.when(stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + "}\n", true));
jenkinsRule.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0));
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetWithRawTemplate.
@Test
public void createChangeSetWithRawTemplate() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(stack.exists()).thenReturn(true);
Mockito.when(stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', template: 'foobaz')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.eq("foobaz"), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyInt(), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString());
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createEmptyChangeSet.
@Test
public void createEmptyChangeSet() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(stack.exists()).thenReturn(true);
Mockito.when(stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED).withStatusReason("The submitted information didn't contain changes. Submit different information to create a change set."));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
jenkinsRule.assertLogContains("changesCount=0", run);
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackDoesNotExist.
@Test
public void createChangeSetStackDoesNotExist() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(stack.exists()).thenReturn(false);
Mockito.when(stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyInt(), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString());
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project pipeline-aws-plugin by jenkinsci.
the class CFNDeleteStackTests method deleteStack.
@Test
public void deleteStack() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " cfnDelete(stack: 'foo')" + "}\n", true));
this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
PowerMockito.verifyNew(CloudFormationStack.class).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).delete(Mockito.anyLong());
}
Aggregations