/** * * @deprecated as of 1.40 * Use {@link #createClientManager(ISVNAuthenticationProvider)} */ public static SVNClientManager createSvnClientManager(ISVNAuthenticationProvider authProvider) { return createClientManager(authProvider).getCore(); }
/** * @deprecated as of 2.0 * Use {@link #createClientManager(AbstractProject)} * */ public static SVNClientManager createSvnClientManager(AbstractProject context) { return createClientManager(context).getCore(); }
@Override public List<External> invoke(File ws, VirtualChannel channel) throws IOException { clientManager = createClientManager(authProvider); manager = clientManager.getCore(); this.ws = ws; try { List<External> externals = perform(); checkClockOutOfSync(); return externals; } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } finally { clientManager.dispose(); } }
/** * Gets the SVN metadata for the remote repository. * * @param remoteUrl * The target to run "svn info". */ static SVNInfo parseSvnInfo(SVNURL remoteUrl, ISVNAuthenticationProvider authProvider) throws SVNException { final SvnClientManager manager = createClientManager(authProvider); try { final SVNWCClient svnWc = manager.getWCClient(); return svnWc.doInfo(remoteUrl, SVNRevision.HEAD, SVNRevision.HEAD); } finally { manager.dispose(); } }
private void changeFiles(String... paths) throws Exception { SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null); for (String path : paths) { FilePath newFile = workingcopy.child(path); newFile.write(new Date().toString(),"UTF-8"); } }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { SVNURL svnUrl = SVNURL.parseURIEncoded(tagUrl); SVNCopyClient copyClient; try { copyClient = SubversionSCM.createClientManager(authProvider).getCopyClient(); } catch (NoSuchMethodError e) { //todo remove when backward compatibility not needed //fallback for older versions of org.jenkins-ci.plugins:subversion buildListener.getLogger().println( "[RELEASE] You are using an old subversion jenkins plugin, please consider upgrading."); copyClient = SubversionSCM.createSvnClientManager(authProvider).getCopyClient(); } buildListener.getLogger().println("[RELEASE] Creating subversion tag: " + tagUrl); SVNCopySource source = new SVNCopySource(SVNRevision.WORKING, SVNRevision.WORKING, workingCopy); SVNCommitInfo commitInfo = copyClient.doCopy(new SVNCopySource[]{source}, svnUrl, false, true, true, commitMessage, new SVNProperties()); SVNErrorMessage errorMessage = commitInfo.getErrorMessage(); if (errorMessage != null) { throw new IOException("Failed to create tag: " + errorMessage.getFullMessage()); } return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed to create tag", e); throw new IOException("Subversion tag creation failed: " + e.getMessage()); } } }
authProvider = defaultAuthProvider; final SvnClientManager manager = createClientManager(authProvider); try { final SVNWCClient svnWc = manager.getWCClient(); final SvnClientManager manager = createClientManager(defaultAuthProvider); try { final SVNWCClient svnWc = manager.getWCClient();
private void changeProperties(String... paths) throws Exception { SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null); for (String path : paths) { FilePath newFile = workingcopy.child(path); svnm.getWCClient().doSetProperty( new File(newFile.getRemote()), "date", SVNPropertyValue.create(new Date().toString()), true, SVNDepth.EMPTY, null, null); } }
private void addFiles(String... paths) throws Exception { SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null); for (String path : paths) { FilePath newFile = workingcopy.child(path); newFile.touch(System.currentTimeMillis()); svnm.getWCClient().doAdd(new File(newFile.getRemote()), false, false, false, SVNDepth.INFINITY, false, false); } }
@Override public String call() throws DebianizingException { SvnClientManager clientManager = SubversionSCM.createClientManager(provider); try { SVNCommitPacket changeset = clientManager.getCommitClient().doCollectCommitItems(new File[] {new File(path)}, false, true, SVNDepth.INFINITY, null); if (changeset != SVNCommitPacket.EMPTY) { SVNCommitInfo commitInfo = clientManager.getCommitClient().doCommit(changeset, false, commitMessage); if (commitInfo.getErrorMessage() != null) { throw new DebianizingException(MessageFormat.format("Error while commiting <{0}>: {1}", path, commitInfo.getErrorMessage().toString())); } else { return Long.toString(commitInfo.getNewRevision()); } } else { throw new DebianizingException("There was nothing to commit."); } } catch (SVNException e) { throw new DebianizingException("SVNException: " + e.getMessage(), e); } finally { clientManager.dispose(); } } }
private void commitWorkingCopy(String comment) throws Exception { SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null); svnm .getCommitClient() .doCommit(new File[] {new File(workingcopy.getRemote())}, false, comment, null, null, false, false, SVNDepth.INFINITY); svnm .getUpdateClient() .doUpdate(new File(workingcopy.getRemote()), SVNRevision.HEAD, SVNDepth.INFINITY, false, false); }
/** * Checks it the revision range [from,to] has any changes that are not excluded via exclusions. */ public boolean findNonExcludedChanges(SVNURL url, long from, long to, ISVNAuthenticationProvider authProvider) throws SVNException { if (from>to) return false; // empty revision range, meaning no change // if no exclusion rules are defined, don't waste time going through "svn log". if (!filter.hasExclusionRule()) return true; final SvnClientManager manager = createClientManager(authProvider); try { manager.getLogClient().doLog(url, null, SVNRevision.UNDEFINED, SVNRevision.create(from), // get log entries from the local revision + 1 SVNRevision.create(to), // to the remote revision false, // Don't stop on copy. true, // Report paths. false, // Don't included merged revisions 0, // Retrieve log entries for unlimited number of revisions. null, // Retrieve all revprops this); } finally { manager.dispose(); } return isChangesFound(); }
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; }
public PathContext invoke(File p, VirtualChannel channel) throws IOException { final SvnClientManager manager = SubversionSCM.createClientManager(authProvider); try { final SVNWCClient svnwc = manager.getWCClient(); SVNInfo info; try { info = svnwc.doInfo(p, SVNRevision.WORKING); String url = info.getURL().toDecodedString(); String repoRoot = info.getRepositoryRootURL().toDecodedString(); return new PathContext(url, repoRoot, null); } catch (SVNException e) { e.printStackTrace(); return null; } } finally { manager.dispose(); } }
/** * Manufactures commits by adding files in the given names. */ private void createCommit(SubversionSCM scm, String... paths) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null); List<File> added = new ArrayList<>(); for (String path : paths) { FilePath newFile = b.getWorkspace().child(path); added.add(new File(newFile.getRemote())); if (!newFile.exists()) { newFile.touch(System.currentTimeMillis()); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); } else newFile.write("random content","UTF-8"); } SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(added.toArray(new File[added.size()]),false,"added",null,null,false,false,SVNDepth.EMPTY); }
CredentialsSVNAuthenticationProviderImpl .createAuthenticationProvider(build.getParent(), scm, l, listener); final SVNClientManager manager = SubversionSCM.createClientManager(authProvider).getCore(); try { SVNLogClient svnlc = manager.getLogClient();
/** * Makes sure that Subversion doesn't check out workspace in 1.6 */ @Email("http://www.nabble.com/SVN-1.6-td24081571.html") @Test public void workspaceVersion() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); p.setScm(loadSvnRepo()); FreeStyleBuild b = p.scheduleBuild2(0).get(); SvnClientManager wc = SubversionSCM.createClientManager((AbstractProject)null); SVNStatus st = wc.getStatusClient().doStatus(new File(b.getWorkspace().getRemote()+"/a"), false); int wcf = st.getWorkingCopyFormat(); System.out.println(wcf); assertEquals(SVNAdminAreaFactory.WC_FORMAT_14,wcf); }
@Test public void masterPolling() throws Exception { File repo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath()); scm.setPollFromMaster(true); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(2).get()); // initial polling on the master for the code path that doesn't find any change assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); // create a commit FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); FilePath newFile = b.getWorkspace().child("foo"); newFile.touch(System.currentTimeMillis()); SvnClientManager svnm = SubversionSCM.createClientManager(p); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(new File[]{new File(newFile.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY); // polling on the master for the code path that doesn't find any change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }
SvnClientManager svnm = SubversionSCM.createClientManager(b); svnm .getUpdateClient()