Skip to content
Permalink
Browse files
Merge pull request #1 from christ66/master
[FIXED JENKINS-20113] - Unable to delete metadata job.
  • Loading branch information
rsandell committed Nov 6, 2013
2 parents 856b69b + dd75798 commit 2842fd93fd1f028a93c1583c18f78516fb4ccec2
@@ -39,6 +39,7 @@
import hudson.model.Saveable;
import hudson.model.User;
import hudson.model.listeners.SaveableListener;
import jenkins.model.Jenkins;

import java.io.IOException;
import java.util.Collection;
@@ -147,6 +148,11 @@ public void run() {
} catch (InterruptedException e) {
logger.finest("interrupted");
}

if (!project.getRootDir().exists()) {
return;
}

MetadataJobProperty property = getOrCreateProperty();
if (property == null) {
return;
@@ -0,0 +1,36 @@
package com.sonyericsson.hudson.plugins.metadata;

import jenkins.model.Jenkins;
import hudson.model.FreeStyleProject;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;

import java.io.File;
import java.text.SimpleDateFormat;

/**
* @author christ66
* Date: 10/14/13
* Time: 7:16 PM
*/
public class DeleteTest extends HudsonTestCase {
// ZD-13803
@Bug(13803)
@Test
public void testDeleteJob() throws Exception {
FreeStyleProject freeStyleProject = jenkins.createProject(FreeStyleProject.class, "test");
freeStyleProject.save();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
System.out.println("Before delete: " + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
freeStyleProject.delete();
Thread.sleep(3 * 1000); // Give it a few seconds to create the file
System.out.println("After delete: " + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
assertFalse("Project should have been deleted", freeStyleProject.getRootDir().exists());
Jenkins.getInstance().restart();
Jenkins.getInstance().doReload();
System.out.println("After reload: " + sdf.format(new File(freeStyleProject.getRootDir(), "config.xml").lastModified()));
assertFalse("Project should have been deleted", freeStyleProject.getRootDir().exists());
assertFalse("Should not be disabled but instead deleted.", !freeStyleProject.isDisabled());
}
}

0 comments on commit 2842fd9

Please sign in to comment.