All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.scm_sync_configuration.HudsonFilesHelper Maven / Gradle / Ivy

Go to download

SCM Sync Configuration Hudson plugin is aimed at 2 main features : First, keep sync'ed your config.xml (and other ressources) hudson files with a SCM repository (backup), Secondly, track changes (and author) made on every file with commit messages.

The newest version!
package hudson.plugins.scm_sync_configuration;

import hudson.model.Hudson;

import java.io.File;

public class HudsonFilesHelper {

	public static String buildPathRelativeToHudsonRoot(File file){
		File hudsonRoot = Hudson.getInstance().getRootDir();
		if(!file.getAbsolutePath().startsWith(hudsonRoot.getAbsolutePath())){
			throw new IllegalArgumentException("Err ! File <"+file.getAbsolutePath()+"> seems not to reside in <"+hudsonRoot.getAbsolutePath()+"> !");
		}
		String truncatedPath = file.getAbsolutePath().substring(hudsonRoot.getAbsolutePath().length()+1); // "+1" because we don't need ending file separator
		return truncatedPath.replaceAll("\\\\", "/"); 
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy