use of com.amazonaws.services.cloudformation.model.DescribeChangeSetResult in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackExists.
@Test
public void createChangeSetStackExists() 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')\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.UPDATE), Mockito.anyString());
}
use of com.amazonaws.services.cloudformation.model.DescribeChangeSetResult in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackParametersFromMap.
@Test
public void createChangeSetStackParametersFromMap() 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', params: ['foo': 'bar', 'baz': 'true'])\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.eq(Arrays.asList(new Parameter().withParameterKey("foo").withParameterValue("bar"), new Parameter().withParameterKey("baz").withParameterValue("true"))), Mockito.anyCollectionOf(Tag.class), Mockito.anyInt(), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString());
}
use of com.amazonaws.services.cloudformation.model.DescribeChangeSetResult 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 com.amazonaws.services.cloudformation.model.DescribeChangeSetResult 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 com.amazonaws.services.cloudformation.model.DescribeChangeSetResult 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);
}
Aggregations