@Override public int hashCode() { return new HashCodeBuilder() .append(remote) .append(getLocalDir()) .append(depthOption) .append(ignoreExternalsOption) .append(repositoryUUID) .append(repositoryRoot).hashCode(); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ModuleLocation)) { return false; } ModuleLocation that = (ModuleLocation) o; return new EqualsBuilder() .append(depthOption, that.depthOption) .append(getLocalDir(), that.getLocalDir()) .append(remote, that.remote) .append(repositoryRoot, that.repositoryRoot) .append(repositoryUUID, that.repositoryUUID) .append(ignoreExternalsOption, that.ignoreExternalsOption) .isEquals(); }
/** * Cleans workspace. * * @throws java.io.IOException IOException */ protected void cleanupBeforeCheckout() throws IOException { for (final SubversionSCM.ModuleLocation location : locations) { File local = new File(ws, location.getLocalDir()); if (listener != null && listener.getLogger() != null) { listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath()); } Util.deleteContentsRecursive(local); } } }
@Override public FilePath getModuleRoot(FilePath workspace, AbstractBuild build) { if (build == null) { return getModuleRoot(workspace); } // TODO: can't I get the build listener here? TaskListener listener = new LogTaskListener(LOGGER, WARNING); final EnvVars env; try { env = build.getEnvironment(listener); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } if (getLocations().length > 0) return _getModuleRoot(workspace, getLocations()[0].getLocalDir(), env); return workspace; }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNCommitClient commitClient = new SVNCommitClient(sam, null); buildListener.getLogger().println("[RELEASE] " + commitMessage); debuggingLogger.fine(String.format("Committing working copy: '%s'", workingCopy)); SVNCommitInfo commitInfo = commitClient.doCommit(new File[]{workingCopy}, true, commitMessage, null, null, true, true, SVNDepth.INFINITY); SVNErrorMessage errorMessage = commitInfo.getErrorMessage(); if (errorMessage != null) { throw new IOException("Failed to commit working copy: " + errorMessage.getFullMessage()); } return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed to Commit WorkingCopy", e); throw new IOException(e.getMessage()); } } }
static ModuleLocation findOurLocation(@SuppressWarnings("rawtypes") AbstractBuild build, SubversionSCM scm, Runner runner, String remoteDebian) throws DebianizingException { EnvVars environment; try { environment = build.getEnvironment(runner.getListener()); } catch (IOException e) { throw new DebianizingException("IOException: " + e.getMessage(), e); } catch (InterruptedException e) { throw new DebianizingException("InterruptedException: " + e.getMessage(), e); } for (ModuleLocation location: scm.getLocations(environment, build)) { if (remoteDebian.startsWith(build.getWorkspace().child(location.getLocalDir()).getRemote())) { return location; } } throw new DebianizingException("Can't find module location for remoteDebian " + remoteDebian); }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { log(listener, "Reverting working copy: " + workingCopy); ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNWCClient wcClient = new SVNWCClient(sam, null); wcClient.doRevert(new File[]{workingCopy}, SVNDepth.INFINITY, null); return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed Revert WorkingCopy ", e); throw new IOException(e.getMessage()); } } }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { log(listener, "Cleanup working copy: " + workingCopy); ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNWCClient wcClient = new SVNWCClient(sam, null); wcClient.doCleanup(workingCopy); return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed Cleanup ", e); throw new IOException(e.getMessage()); } } }
/** * Cleans workspace. * * @throws java.io.IOException IOException */ protected void cleanupBeforeCheckout() throws IOException { for (final SubversionSCM.ModuleLocation location : locations) { File local = new File(ws, location.getLocalDir()); if (listener != null && listener.getLogger() != null) { listener.getLogger().println("Cleaning checkout folder " + local.getCanonicalPath()); } Util.deleteContentsRecursive(local); } } }
@Override public FilePath[] getModuleRoots(FilePath workspace) { final ModuleLocation[] moduleLocations = getLocations(); if (moduleLocations.length > 0) { FilePath[] moduleRoots = new FilePath[moduleLocations.length]; for (int i = 0; i < moduleLocations.length; i++) { moduleRoots[i] = workspace.child(moduleLocations[i].getLocalDir()); } return moduleRoots; } return new FilePath[]{getModuleRoot(workspace)}; }
@Deprecated @Override public FilePath[] getModuleRoots(FilePath workspace) { final ModuleLocation[] moduleLocations = getLocations(); if (moduleLocations.length > 0) { FilePath[] moduleRoots = new FilePath[moduleLocations.length]; for (int i = 0; i < moduleLocations.length; i++) { moduleRoots[i] = workspace.child(moduleLocations[i].getLocalDir()); } return moduleRoots; } return new FilePath[] { getModuleRoot(workspace) }; }
@Override public FilePath[] getModuleRoots(FilePath workspace) { final ModuleLocation[] moduleLocations = getLocations(); if (moduleLocations.length > 0) { FilePath[] moduleRoots = new FilePath[moduleLocations.length]; for (int i = 0; i < moduleLocations.length; i++) { moduleRoots[i] = workspace.child(moduleLocations[i].getLocalDir()); } return moduleRoots; } return new FilePath[]{getModuleRoot(workspace)}; }
/** * Expand location value based on environment variables. * * @return Output ModuleLocation expanded according to specified env vars. */ public ModuleLocation getExpandedLocation(EnvVars env) { return new ModuleLocation(env.expand(remote), credentialsId, env.expand(getLocalDir()), getDepthOption(), isIgnoreExternalsOption(), isCancelProcessOnExternalsFail()); }
/** * Expand location value based on Build parametric execution. * * @param build Build instance for expanding parameters into their values * @return Output ModuleLocation expanded according to Build parameters * values. */ public ModuleLocation getExpandedLocation(AbstractBuild<?, ?> build) { return new ModuleLocation(getExpandedRemote(build), getLocalDir(), getDepthOption(), isIgnoreExternalsOption()); }
@Override public FilePath getModuleRoot(FilePath workspace) { if (getLocations().length > 0) { return workspace.child(getLocations()[0].getLocalDir()); } return workspace; }
@Issue("JENKINS-10943") @Test public void getLocalDirWithAtRevision() throws Exception { // remote is not configured. SubversionSCM scm = new SubversionSCM("http://localhost/project@100", null); ModuleLocation[] locs = scm.getLocations(); assertEquals(1, locs.length); assertEquals("project", locs[0].getLocalDir()); }
/** * @deprecated This method is used by {@link #getExpandedLocation(AbstractBuild)} * which is deprecated since it expands variables only based * on build parameters. */ private String getExpandedLocalDir(AbstractBuild<?,?> build) { String outLocalDir = getLocalDir(); ParametersAction parameters = build.getAction(ParametersAction.class); if (parameters != null) outLocalDir = parameters.substitute(build, getLocalDir()); return outLocalDir; }
/** * @deprecated */ @Override @Deprecated public FilePath getModuleRoot(FilePath workspace) { if (getLocations().length > 0) return workspace.child(getLocations()[0].getLocalDir()); return workspace; }
/** * Expand location value based on Build parametric execution. * * @param build Build instance for expanding parameters into their values * @return Output ModuleLocation expanded according to Build parameters * values. */ public ModuleLocation getExpandedLocation(AbstractBuild<?, ?> build) { return new ModuleLocation(getExpandedRemote(build), getLocalDir(), getDepthOption(), isIgnoreExternalsOption()); }
@Override public FilePath getModuleRoot(FilePath workspace) { if (getLocations().length > 0) { return workspace.child(getLocations()[0].getLocalDir()); } return workspace; }