Skip to content
Permalink
Browse files

[FIXED JENKINS-18694] Generalizing fix of JENKINS-18678 to include al…

…so rename of parent folders, taking advantage of JENKINS-18028 API.
  • Loading branch information
jglick committed Jan 9, 2014
1 parent c21b209 commit cb623640ccd820ad0540efc3b50cc596626e43a2
@@ -66,6 +66,9 @@
<li class=bug>
<i>Apply</i> buttons did not work in Internet Explorer in compatibility mode.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19826">issue 19826</a>)
<li class="major bug">
Builds can seem to disappear from a job in a folder if that folder is renamed.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18694">issue 18694</a>)
<li class=bug>
<code>/login</code> offers link to <code>/opensearch.xml</code> which anonymous users cannot retrieve.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21254">issue 21254</a>)
@@ -27,15 +27,16 @@
*/
package hudson.model;

import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.EnvVars;
import hudson.ExtensionPoint;
import hudson.Functions;
import antlr.ANTLRException;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.AbortException;
import hudson.CopyOnWrite;
import hudson.EnvVars;
import hudson.Extension;
import hudson.ExtensionPoint;
import hudson.FeedAdapter;
import hudson.FilePath;
import hudson.Functions;
import hudson.Launcher;
import hudson.Util;
import hudson.cli.declarative.CLIMethod;
@@ -48,21 +49,23 @@
import hudson.model.PermalinkProjectAction.Permalink;
import hudson.model.Queue.Executable;
import hudson.model.Queue.Task;
import hudson.model.queue.QueueTaskFuture;
import hudson.model.queue.ScheduleResult;
import hudson.model.queue.SubTask;
import hudson.model.RunMap.Constructor;
import hudson.model.labels.LabelAtom;
import hudson.model.labels.LabelExpression;
import hudson.model.listeners.ItemListener;
import hudson.model.listeners.SCMPollListener;
import hudson.model.queue.CauseOfBlockage;
import hudson.model.queue.QueueTaskFuture;
import hudson.model.queue.ScheduleResult;
import hudson.model.queue.SubTask;
import hudson.model.queue.SubTaskContributor;
import hudson.node_monitors.DiskSpaceMonitor;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.Entry;
import hudson.scm.NullSCM;
import hudson.scm.PollingResult;

import static hudson.scm.PollingResult.*;
import hudson.scm.SCM;
import hudson.scm.SCMRevisionState;
import hudson.scm.SCMS;
@@ -85,6 +88,32 @@
import hudson.util.TimeUnit2;
import hudson.widgets.BuildHistoryWidget;
import hudson.widgets.HistoryWidget;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import static javax.servlet.http.HttpServletResponse.*;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import jenkins.model.ModelObjectWithChildren;
@@ -100,6 +129,7 @@
import org.acegisecurity.context.SecurityContextHolder;
import org.jenkinsci.bytecode.AdaptField;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
@@ -115,35 +145,6 @@
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.interceptor.RequirePOST;

import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
import java.util.logging.Logger;

import static hudson.scm.PollingResult.*;
import javax.annotation.CheckForNull;
import static javax.servlet.http.HttpServletResponse.*;

/**
* Base implementation of {@link Job}s that build software.
*
@@ -1672,13 +1673,6 @@ void addToList( T item, List<T> collection ) throws IOException {
updateTransientActions();
}

@Override
public void renameTo(String newName) throws IOException {
super.renameTo(newName);
// Update locations inside builds cache
builds.updateBaseDir(getBuildDir());
}

protected final synchronized <T extends Describable<T>>
void removeFromList(Descriptor<T> item, List<T> collection) throws IOException {
final Iterator<T> iCollection = collection.iterator();
@@ -2422,4 +2416,14 @@ public void setCustomWorkspace(String customWorkspace) throws IOException {
public abstract FormValidation check(@Nonnull AbstractProject<?, ?> project, @Nonnull Label label);
}

@Restricted(DoNotUse.class)
@Extension public static final class ItemListenerImpl extends ItemListener {
@Override public void onLocationChanged(Item item, String oldFullName, String newFullName) {
if (item instanceof AbstractProject) {
AbstractProject p = (AbstractProject) item;
p.builds.updateBaseDir(p.getBuildDir());
}
}
}

}
@@ -388,6 +388,10 @@ public class AbstractProjectTest extends HudsonTestCase {
assertEquals(p, jenkins.getItemByFullName("d/edited"));
p._getRuns().purgeCache();
assertEquals(1, p.getBuilds().size());
d.renameTo("d2");
p = jenkins.getItemByFullName("d2/edited");
p._getRuns().purgeCache();
assertEquals(1, p.getBuilds().size());
}

@Bug(17575)

0 comments on commit cb62364

Please sign in to comment.
You can’t perform that action at this time.