private void checkClockOutOfSync() { try { for (ModuleLocation l : locations) { SVNDirEntry dir = manager.createRepository(l.getSVNURL(), true).info("/", -1); // see http://www.nabble.com/NullPointerException-in-SVN-Checkout-Update-td21609781.html that reported this being null. if (dir != null && dir.getDate() != null && dir.getDate().after(new Date())) { listener.getLogger().println(Messages.SubversionSCM_ClockOutOfSync()); } } } catch (SVNAuthenticationException e) { // if we don't have access to '/', ignore. error LOGGER.log(Level.FINE, "Failed to estimate the remote time stamp", e); } catch (SVNException e) { LOGGER.log(Level.INFO, "Failed to estimate the remote time stamp", e); } }
private void checkClockOutOfSync() { try { SVNDirEntry dir = clientManager.createRepository(location.getSVNURL(), true).info("/", -1); if (dir != null) {// I don't think this can ever be null, but be defensive if (dir.getDate() != null && dir.getDate().after(new Date())) // see http://www.nabble.com/NullPointerException-in-SVN-Checkout-Update-td21609781.html that reported this being null. { listener.getLogger().println(Messages.SubversionSCM_ClockOutOfSync()); } } } catch (SVNAuthenticationException e) { // if we don't have access to '/', ignore. error LOGGER.log(Level.FINE,"Failed to estimate the remote time stamp",e); } catch (SVNException e) { LOGGER.log(Level.INFO,"Failed to estimate the remote time stamp",e); } }
private void checkClockOutOfSync() { try { for (ModuleLocation l : locations) { SVNDirEntry dir = manager.createRepository(l.getSVNURL(), true).info("/", -1); // see http://www.nabble.com/NullPointerException-in-SVN-Checkout-Update-td21609781.html that reported this being null. if (dir != null && dir.getDate() != null && dir.getDate().after(new Date())) { listener.getLogger().println(Messages.SubversionSCM_ClockOutOfSync()); } } } catch (SVNAuthenticationException e) { // if we don't have access to '/', ignore. error LOGGER.log(Level.FINE, "Failed to estimate the remote time stamp", e); } catch (SVNException e) { LOGGER.log(Level.INFO, "Failed to estimate the remote time stamp", e); } }
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:
String revisionName = r.getDate() != null ? fmt.format(r.getDate()) : r.toString(); listener.getLogger().println("Checking out " + location.getSVNURL().toString() + " at revision " + revisionName + (quietOperation ? " --quiet" : "")); 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);
if (remoteUUID.equals(uuid)) uuidFound = true; else continue; String configuredRepoFullPath = loc.getSVNURL().getPath(); String rootRepoPath = uuidAndRootPath.rootPath; if (this.doModuleLocationHasAPathFromAffectedPath(configuredRepoFullPath, rootRepoPath, affectedPath)) {
svnuc.setEventHandler( new SubversionUpdateEventHandler(new PrintStream(pos), externals, local, l.getLocalDir())); svnuc.doCheckout(l.getSVNURL(), local.getCanonicalFile(), SVNRevision.HEAD, revision, svnDepth, true);
(revision != null ? revision.toString() : "null") + " depth:" + svnDepth + " ignoreExternals: " + l.isIgnoreExternalsOption()); svnuc.doSwitch(local.getCanonicalFile(), l.getSVNURL(), SVNRevision.HEAD, revision, svnDepth, true, false); } catch (final SVNException e) {
public SVNRepository openRepository(Job context, SCM scm, boolean keepConnection) throws SVNException { SVNURL repoURL = getSVNURL();
SVNInfo svnInfo = parseSvnInfo(module); String url = location.getSVNURL().toString(); String wcUrl = svnInfo.getURL().toString();
/** * @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; }
@Override public SCMFileSystem build(Item owner, SCM scm, SCMRevision rev) throws IOException, InterruptedException { if (rev != null && !(rev instanceof SubversionSCMSource.SCMRevisionImpl)) { return null; } try { SubversionSCM svn = (SubversionSCM) scm; ModuleLocation moduleLocation = svn.getLocations()[0]; StandardCredentials credentials = null; SVNURL repoURL = moduleLocation.getSVNURL(); if (moduleLocation.credentialsId != null) { credentials = CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(StandardCredentials.class, owner, ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()), CredentialsMatchers.allOf(CredentialsMatchers.withId(moduleLocation.credentialsId), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardCredentials.class), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)))); } SVNRepository repository = createRepository(repoURL, credentials); return new SubversionSCMFileSystem(repository, rev); } catch (SVNException e) { throw new IOException("failed to create SVNRepositoryView", e); } }
static List<Change> getChangesFromSubversion(@SuppressWarnings("rawtypes") AbstractBuild build, final Runner runner, SubversionSCM scm, final String remoteDebian, String latestRevision, String currentRevision, final String ourMessage) throws DebianizingException { final List<Change> result = new ArrayList<Change>(); ModuleLocation location = findOurLocation(build, scm, runner, remoteDebian); ISVNAuthenticationProvider authenticationProvider = ((SubversionSCM)build.getProject().getScm()).createAuthenticationProvider(build.getProject(), location); SvnClientManager manager = SubversionSCM.createClientManager(authenticationProvider); try { SVNURL svnurl = location.getSVNURL(); manager.getLogClient().doLog(svnurl, null, SVNRevision.UNDEFINED, SVNRevision.create(Long.parseLong(latestRevision) + 1), SVNRevision.parse(currentRevision), false, true, 0, new ISVNLogEntryHandler() { @Override public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { if (!logEntry.getMessage().equals(ourMessage)) { result.add(new Change(logEntry.getAuthor(), logEntry.getMessage())); } } }); } catch (SVNException e) { e.printStackTrace(); throw new DebianizingException("SVNException: " + e.getMessage(), e); } finally { manager.dispose(); } return result; }
/*package*/ void migrateCredentials(SubversionSCM.DescriptorImpl descriptor) throws IOException { Iterable<CredentialsStore> it = CredentialsProvider.lookupStores(project); if (it != null && it.iterator().hasNext()) { CredentialsStore store = it.iterator().next(); for (Map.Entry<String, Credential> e : credentials.entrySet()) { StandardCredentials credential = descriptor.migrateCredentials(store, e.getKey(), e.getValue()); ModuleLocation[] locations = ((SubversionSCM) project.getScm()).getLocations(); for (int i = 0; i < locations.length; i++) { try { if (e.getKey().contains(locations[i].getSVNURL().getHost())) { locations[i].setCredentialsId(credential.getId()); break; } } catch (SVNException ex) { // Should not happen, but... LOGGER.log(WARNING, "Repository location with a malformed URL: " + locations[i].remote, ex); } } } } } }
public boolean repositoryLocationsNoLongerExist(AbstractBuild<?, ?> build, TaskListener listener) { PrintStream out = listener.getLogger(); for (ModuleLocation l : getLocations(build)) { try { if (getDescriptor().checkRepositoryPath(build.getProject(), 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(Level.FINE, "Location check failed", e); } } return false; }
public boolean repositoryLocationsNoLongerExist(AbstractBuild<?, ?> build, TaskListener listener) { PrintStream out = listener.getLogger(); for (ModuleLocation l : getLocations(build)) { try { if (getDescriptor().checkRepositoryPath(build.getProject(), 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(Level.FINE, "Location check failed", e); } } return false; }
static String getSVNRevision(@SuppressWarnings("rawtypes") AbstractBuild build, Runner runner, SubversionSCM scm, String remoteDebian) throws DebianizingException { ModuleLocation location = findOurLocation(build, scm, runner, remoteDebian); try { Map<String, Long> revisionsForBuild = SubversionHack.getRevisionsForBuild(scm, build); return Long.toString(revisionsForBuild.get(location.getSVNURL().toString())); } catch (IOException e) { throw new DebianizingException("IOException: " + e.getMessage(), e); } catch (SVNException e) { throw new DebianizingException("SVNException: " + e.getMessage(), e); } catch (InterruptedException e) { throw new DebianizingException("InterruptedException: " + e.getMessage(), e); } catch (IllegalArgumentException e) { throw new DebianizingException("IllegalArgumentException: " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new DebianizingException("IllegalAccessException: " + e.getMessage(), e); } }
public SVNRepository openRepository(AbstractProject context) throws SVNException { return Hudson.getInstance().getDescriptorByType(DescriptorImpl.class).getRepository(context, getSVNURL()); }
private boolean isSameRepository(ModuleLocation location, SVNInfo svnkitInfo) throws SVNException { return location.getSVNURL().toString().startsWith(svnkitInfo.getRepositoryRootURL().toString()); }
public SVNRepository openRepository(AbstractProject context) throws SVNException { return Hudson.getInstance().getDescriptorByType(DescriptorImpl.class).getRepository(context, getSVNURL()); }