Skip to content

Commit

Permalink
Improve disposal test on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlaverse committed Jul 16, 2018
1 parent 5f93c0f commit a5a8471
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void testUsernamePasswordWithSpace() throws Exception {
public void testKubeConfigDisposed() throws Exception {
CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), usernamePasswordCredentialWithSpace(CREDENTIAL_ID));

WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "testUsernamePasswordWithSpace");
p.setDefinition(new CpsFlowDefinition(loadResource("mockedKubectl.groovy"), true));
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "testCleanupOnFailure");
p.setDefinition(new CpsFlowDefinition(loadResource("mockedKubectlFailure.groovy"), true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
assertNotNull(b);
r.assertBuildStatusSuccess(r.waitForCompletion(b));
r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b));
r.assertLogContains("kubectl configuration cleaned up", b);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node{
label "mocked-kubectl"
stage('Run') {
withKubeConfig([credentialsId: 'cred1234', serverUrl: 'https://localhost:6443']) {
sleep(1)
echo "File has been configured '${env.KUBECONFIG}'"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node{
label "mocked-kubectl"
stage('Run') {
withKubeConfig([credentialsId: 'cred1234', serverUrl: 'https://localhost:6443']) {
sleep(1)
error("Build failed because of this and that..")
}
}
}

0 comments on commit a5a8471

Please sign in to comment.