We’ve find out that following source changes on Jenkins version 1.606 are a workaround to handle the issue.

1. Adaption on Run.java on the method delete()

Run.java
/**
     * Deletes this build and its entire log
     *
     * @throws IOException
     *      if we fail to delete.
     */
    public void delete() throws IOException {
        
		File rootDir = getRootDir();
        if (!rootDir.isDirectory()) {
		    LOGGER.log(Level.WARNING, "IOException: " + rootDir + " looks to have already been deleted; siblings: " + Arrays.toString(project.getBuildDir().list()));
            //throw new IOException(this + ": " + rootDir + " looks to have already been deleted; siblings: " + Arrays.toString(project.getBuildDir().list()));
        }
        
        RunListener.fireDeleted(this);

        synchronized (this) { // avoid holding a lock while calling plugin impls of onDeleted
        File tmp = new File(rootDir.getParentFile(),'.'+rootDir.getName());
        
        if (tmp.exists()) {
            Util.deleteRecursive(tmp);
        }
        // TODO on Java 7 prefer: Files.move(rootDir.toPath(), tmp.toPath(), StandardCopyOption.ATOMIC_MOVE)
        boolean renamingSucceeded = rootDir.renameTo(tmp);
        Util.deleteRecursive(tmp);
        // some user reported that they see some left-over .xyz files in the workspace,
        // so just to make sure we've really deleted it, schedule the deletion on VM exit, too.
        if(tmp.exists())
            tmp.deleteOnExit();

        if(!renamingSucceeded) {
            LOGGER.log(Level.WARNING, rootDir+" is in use");
			//throw new IOException(rootDir+" is in use");
		}
        LOGGER.log(FINE, "{0}: {1} successfully deleted", new Object[] {this, rootDir});

        removeRunFromParent();
        }
    }

2. Adaption on LogRotator.java on the method perform(Job<?,?> job)

LogRotator.java
public void perform(Job<?,?> job) throws IOException, InterruptedException {
        LOGGER.log(FINE, "Running the log rotation for {0} with numToKeep={1} daysToKeep={2} artifactNumToKeep={3} artifactDaysToKeep={4}", new Object[] {job, numToKeep, daysToKeep, artifactNumToKeep, artifactDaysToKeep});
        
        // always keep the last successful and the last stable builds
        Run lsb = job.getLastSuccessfulBuild();
        Run lstb = job.getLastStableBuild();

        if(numToKeep!=-1) {
            // Note that RunList.size is deprecated, and indeed here we are loading all the builds of the job.
            // However we would need to load the first numToKeep anyway, just to skip over them;
            // and we would need to load the rest anyway, to delete them.
            // (Using RunMap.headMap would not suffice, since we do not know if some recent builds have been deleted for other reasons,
            // so simply subtracting numToKeep from the currently last build number might cause us to delete too many.)
			
			try
			{
				List<? extends Run<?,?>> builds = job.getBuilds();
				for (Run r : copy(builds.subList(Math.min(builds.size(), numToKeep), builds.size()))) {
					if (shouldKeepRun(r, lsb, lstb)) {
						continue;
					}
					LOGGER.log(FINE, "{0} is to be removed", r);
					r.delete();
				}
			}
			catch(Exception e)
			{
				LOGGER.log(FINE, "subList creating failed", e);
			}
        }
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to