File local = new File(ws, location.getLocalDir()); SubversionUpdateEventHandler eventHandler = new SubversionUpdateEventHandler( listener.getLogger(), externals, local, location.getLocalDir(), quietOperation, location.isCancelProcessOnExternalsFail()); svnuc.setEventHandler(eventHandler); svnuc.setExternalsHandler(eventHandler); fmt.format(r.getDate()) : r.toString(); svnuc.setIgnoreExternals(location.isIgnoreExternalsOption()); preUpdate(location, local); SVNDepth svnDepth = location.getSvnDepthForUpdate(); listener.getLogger().println("Switching to " + location.remote + " at revision " + revisionName + (quietOperation ? " --quiet" : "")); svnuc.doSwitch(local.getCanonicalFile(), location.getSVNURL(), r, r, svnDepth, true, true, true); break; case CHECKOUT:
oldLocations.add(new ModuleLocation(remoteLoc, null)); outLocations[i] = locations[i].getExpandedLocation(env2);
if (loc.getUUID(p).equals(uuid)) { uuidFound = true; } else { String m = loc.getSVNURL().getPath(); String n = loc.getRepositoryRoot(p).getPath(); if (!m.startsWith(n)) { continue; // repository root should be a subpath of the module path, but be defensive SvnInfo info[] = {new SvnInfo(loc.getURL(), rev)}; RevisionParameterAction action = new RevisionParameterAction(info); actions = new RevisionParameterAction[]{action};
url = loc.getSVNURL().toDecodedString(); } catch (SVNException ex) { listener.error(Messages.SubversionSCM_pollChanges_exception(loc.getURL())); return BUILD_NOW; String url; try { url = loc.getExpandedLocation(project).getSVNURL().toDecodedString(); } catch (SVNException ex) { ex.printStackTrace(listener.error(Messages.SubversionSCM_pollChanges_exception(loc.getURL()))); return BUILD_NOW;
if (loc.getUUID(p).equals(uuid)) uuidFound = true; else continue; String m = loc.getSVNURL().getPath(); String n = loc.getRepositoryRoot(p).getPath(); if(!m.startsWith(n)) continue; // repository root should be a subpath of the module path, but be defensive SvnInfo info[] = { new SvnInfo(loc.getURL(), rev) }; RevisionParameterAction action = new RevisionParameterAction(info); actions = new RevisionParameterAction[] {action};
final List<External> externals = new ArrayList<External>(); // store discovered externals to here listener.getLogger().println("Cleaning local Directory " + location.getLocalDir()); Util.deleteContentsRecursive(new File(ws, location.getLocalDir())); String revisionName = r.getDate() != null ? fmt.format(r.getDate()) : r.toString(); listener.getLogger().println("Checking out " + location.getSVNURL().toString() + " at revision " + revisionName + (quietOperation ? " --quiet" : "")); File local = new File(ws, location.getLocalDir()); SubversionUpdateEventHandler eventHandler = new SubversionUpdateEventHandler( new PrintStream(pos), externals, local, location.getLocalDir(), quietOperation, location.isCancelProcessOnExternalsFail()); svnuc.setEventHandler(eventHandler); svnuc.setExternalsHandler(eventHandler); svnuc.setIgnoreExternals(location.isIgnoreExternalsOption()); SVNDepth svnDepth = location.getSvnDepthForCheckout(); SvnCheckout checkout = svnuc.getOperationsFactory().createCheckout(); checkout.setSource(SvnTarget.fromURL(location.getSVNURL(), SVNRevision.HEAD)); checkout.setSingleTarget(SvnTarget.fromFile(local.getCanonicalFile())); checkout.setDepth(svnDepth); checkout.setRevision(r); checkout.setAllowUnversionedObstructions(true); checkout.setIgnoreExternals(location.isIgnoreExternalsOption()); checkout.setExternalsHandler(SvnCodec.externalsHandler(svnuc.getExternalsHandler()));
for (final ModuleLocation l : locations) { location = l; SVNDepth svnDepth = getSvnDepth(l.getDepthOption()); SVNRevision revision = getRevision(l); if (listener != null) { listener.getLogger().println("Checking out " + l.remote + " revision: " + (revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); File local = new File(ws, l.getLocalDir()); svnuc.setIgnoreExternals(l.isIgnoreExternalsOption()); SubversionUpdateEventHandler handler = new SubversionUpdateEventHandler(new PrintStream(pos), externals, local, l.getLocalDir()); svnuc.setEventHandler(handler); svnuc.setExternalsHandler(handler); checkout.setSource(SvnTarget.fromURL(l.getSVNURL(), SVNRevision.HEAD)); checkout.setSingleTarget(SvnTarget.fromFile(local.getCanonicalFile())); checkout.setRevision(revision);
File local = new File(ws, l.getLocalDir()); SubversionUpdateEventHandler handler = new SubversionUpdateEventHandler(listener.getLogger(), externals, local, l.getLocalDir()); svnuc.setEventHandler(handler); svnuc.setExternalsHandler(handler); svnuc.setIgnoreExternals(l.isIgnoreExternalsOption()); preUpdate(l, local); SVNDepth svnDepth = getSvnDepth(l.getDepthOption()); SVNRevision revision = getRevision(l); " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doSwitch(local.getCanonicalFile(), l.getSVNURL(), SVNRevision.HEAD, revision, svnDepth, true, false); } catch (final SVNException e) {
File local = new File(ws, l.getLocalDir()); SubversionUpdateEventHandler handler = new SubversionUpdateEventHandler(listener.getLogger(), externals, local, l.getLocalDir()); svnuc.setEventHandler(handler); svnuc.setExternalsHandler(handler); svnuc.setIgnoreExternals(l.isIgnoreExternalsOption()); preUpdate(l, local); SVNDepth svnDepth = getSvnDepth(l.getDepthOption()); SVNRevision revision = getRevision(l); " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doUpdate(local.getCanonicalFile(), revision, svnDepth, true, false); } catch (final SVNException e) {
public SVNRepository openRepository(Job context, SCM scm, boolean keepConnection) throws SVNException { SVNURL repoURL = getSVNURL();
for (final ModuleLocation l : locations) { location = l; SVNDepth svnDepth = getSvnDepth(l.getDepthOption()); SVNRevision revision = getRevision(l); if (listener != null) { listener.getLogger().println("Checking out " + l.remote + " revision: " + (revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); File local = new File(ws, l.getLocalDir()); svnuc.setIgnoreExternals(l.isIgnoreExternalsOption()); svnuc.setEventHandler( new SubversionUpdateEventHandler(new PrintStream(pos), externals, local, l.getLocalDir())); svnuc.doCheckout(l.getSVNURL(), local.getCanonicalFile(), SVNRevision.HEAD, revision, svnDepth, true);
File local = new File(ws, l.getLocalDir()); svnuc.setEventHandler(new SubversionUpdateEventHandler(listener.getLogger(), externals, local, l.getLocalDir())); svnuc.setIgnoreExternals(l.isIgnoreExternalsOption()); preUpdate(l, local); SVNDepth svnDepth = getSvnDepth(l.getDepthOption()); SVNRevision revision = getRevision(l); " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doUpdate(local.getCanonicalFile(), revision, svnDepth, true, false);
ModuleLocation expandedLocation = locations[i].getExpandedLocation(job); if (expandedLocation.getRevision(null) != null) { int idx = expandedRemote.lastIndexOf('@'); if (idx >= 0) {
ExecutionException { File repo = new CopyExisting(getClass().getResource("JENKINS-10449.zip")).allocate(); SubversionSCM scm = new SubversionSCM(ModuleLocation.parse(new String[]{"file://" + repo.toURI().toURL().getPath()}, new String[]{"."},null,null), new UpdateUpdater(), null, "/z.*", "", "", "", "", false, shouldFilterLog, null);
String moduleName = location.getLocalDir(); File module = new File(ws, moduleName).getCanonicalFile(); // canonicalize to remove ".." and ".". See #474 SVNInfo svnInfo = parseSvnInfo(module); String url = location.getSVNURL().toString(); String wcUrl = svnInfo.getURL().toString();
oldLocations.add(new ModuleLocation(remoteLoc, null)); outLocations[i] = locations[i].getExpandedLocation(build);
oldLocations.add(new ModuleLocation(remoteLoc, null)); outLocations[i] = locations[i].getExpandedLocation(build);
String moduleName = l.getLocalDir(); File module = new File(ws,moduleName).getCanonicalFile(); // canonicalize to remove ".." and ".". See #474 SvnInfo svnInfo = new SvnInfo(svnkitInfo); String url = l.getURL(); if(!svnInfo.url.equals(url)) { listener.getLogger().println("Checking out a fresh workspace because the workspace is not "+url);
/** * Sets the <tt>SVN_REVISION</tt> environment variable during the build. */ @Override public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); ModuleLocation[] svnLocations = getLocations(build); try { Map<String, Long> revisions = parseRevisionFile(build); if (svnLocations.length == 1) { Long rev = revisions.get(svnLocations[0].remote); if (rev != null) { env.put("SVN_REVISION", rev.toString()); env.put("SVN_URL", svnLocations[0].getURL()); } } else if (svnLocations.length > 1) { for (int i = 0; i < svnLocations.length; i++) { Long rev = revisions.get(svnLocations[i].remote); if (rev != null) { env.put("SVN_REVISION_" + (i + 1), rev.toString()); env.put("SVN_URL_" + (i + 1), svnLocations[i].getURL()); } } } } catch (IOException e) { // ignore this error LOGGER.log(Level.FINEST, "Exception while building envVars. Error will be ignored.", e); } }
/** * @since 1.34 */ public boolean repositoryLocationsNoLongerExist(Run<?,?> build, TaskListener listener, EnvVars env) { PrintStream out = listener.getLogger(); for (ModuleLocation l : getLocations(env, build)) try { if (getDescriptor().checkRepositoryPath(build.getParent(), l.getSVNURL(), lookupCredentials(build.getParent(), l.credentialsId, l.getSVNURL())) == SVNNodeKind.NONE) { out.println("Location '" + l.remote + "' does not exist"); ParametersAction params = build.getAction(ParametersAction.class); if (params != null) { // since this is used to disable projects, be conservative LOGGER.fine("Location could be expanded on build '" + build + "' parameters values:"); return false; } return true; } } catch (SVNException e) { // be conservative, since we are just trying to be helpful in detecting // non existent locations. If we can't detect that, we'll do nothing LOGGER.log(FINE, "Location check failed",e); } return false; }