private static RepositoryBrowser<?> browserFromBuild(AbstractBuild<?,?> build) { if (build == null) { // not generally allowed, but sometimes done in unit tests return null; } return build.getParent().getScm().getEffectiveBrowser(); }
@Deprecated public void onChangeLogParsed(AbstractBuild<?,?> build, BuildListener listener, ChangeLogSet<?> changelog) throws Exception { if (Util.isOverridden(SCMListener.class, getClass(), "onChangeLogParsed", Run.class, SCM.class, TaskListener.class, ChangeLogSet.class)) { onChangeLogParsed((Run) build, build.getProject().getScm(), listener, changelog); } }
@Override public Collection<? extends SCM> getSCMs() { return resolveMultiScmIfConfigured(delegate.asProject().getScm()); } }
@Deprecated public ChangeLogSet<? extends Entry> parse(AbstractBuild build, File changelogFile) throws IOException, SAXException { return parse((Run) build, build.getProject().getScm().getEffectiveBrowser(), changelogFile); } }
/** * Returns the root directory of the checked-out module. * <p> * This is usually where {@code pom.xml}, {@code build.xml} * and so on exists. */ public final FilePath getModuleRoot() { FilePath ws = getWorkspace(); if (ws==null) return null; return getParent().getScm().getModuleRoot(ws, this); }
/** * Returns the root directories of all checked-out modules. * <p> * Some SCMs support checking out multiple modules into the same workspace. * In these cases, the returned array will have a length greater than one. * @return The roots of all modules checked out from the SCM. */ public FilePath[] getModuleRoots() { FilePath ws = getWorkspace(); if (ws==null) return null; return getParent().getScm().getModuleRoots(ws, this); }
/** * Pushes the baseline up to the newly checked out revision. */ private void calcPollingBaseline(AbstractBuild build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { SCMRevisionState baseline = build.getAction(SCMRevisionState.class); if (baseline==null) { try { baseline = getScm().calcRevisionsFromBuild(build, launcher, listener); } catch (AbstractMethodError e) { baseline = SCMRevisionState.NONE; // pre-1.345 SCM implementations, which doesn't use the baseline in polling } if (baseline!=null) build.addAction(baseline); } pollingBaseline = baseline; }
if(!p.getScm().processWorkspaceBeforeDeletion((Job<?, ?>) p,dir,n)) { LOGGER.log(Level.FINE, "Directory deletion of {0} is vetoed by SCM", dir); return false;
/** * Picks up a {@link RepositoryBrowser} that matches the * given {@link SCM} from existing other jobs. * * @return * null if no applicable configuration was found. */ private RepositoryBrowser infer() { for( AbstractProject p : Jenkins.getInstance().allItems(AbstractProject.class) ) { SCM scm = p.getScm(); if (scm!=null && scm.getClass()==owner.getClass() && scm.getBrowser()!=null && ((SCMDescriptor)scm.getDescriptor()).isBrowserReusable(scm,owner)) { return scm.getBrowser(); } } return null; } }
public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException { SCM scm = getScm(); if(scm==null) return true; // no SCM FilePath workspace = build.getWorkspace(); if(workspace!=null){ workspace.mkdirs(); } else { throw new AbortException("Cannot checkout SCM, workspace is not defined"); } boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile); if (r) { // Only calcRevisionsFromBuild if checkout was successful. Note that modern SCM implementations // won't reach this line anyway, as they throw AbortExceptions on checkout failure. calcPollingBaseline(build, launcher, listener); } return r; }
@Override protected void performDelete() throws IOException, InterruptedException { // prevent a new build while a delete operation is in progress makeDisabled(true); FilePath ws = getWorkspace(); if(ws!=null) { Node on = getLastBuiltOn(); getScm().processWorkspaceBeforeDeletion(this, ws, on); if(on!=null) on.getFileSystemProvisioner().discardWorkspace(this,ws); } super.performDelete(); }
SCM scm = getScm(); if (scm==null) { listener.getLogger().println(Messages.AbstractProject_NoSCM());
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
/** * Wipes out the workspace. */ @RequirePOST public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException { checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD); R b = getSomeBuildWithWorkspace(); FilePath ws = b!=null ? b.getWorkspace() : null; if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) { ws.deleteRecursive(); for (WorkspaceListener wl : WorkspaceListener.all()) { wl.afterDelete(this); } return new HttpRedirect("."); } else { // If we get here, that means the SCM blocked the workspace deletion. return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly"); } }
/** * For reasons I don't understand, if I inline this method, * AbstractMethodError escapes try/catch block. */ private SCMRevisionState safeCalcRevisionsFromBuild(AbstractBuild build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { return getScm()._calcRevisionsFromBuild(build, launcher, listener); }
/** * Returns the root directory of the checked-out module. * <p> * This is usually where <tt>pom.xml</tt>, <tt>build.xml</tt> * and so on exists. */ public final FilePath getModuleRoot() { FilePath ws = getWorkspace(); if (ws==null) return null; return getParent().getScm().getModuleRoot(ws,this); }
private boolean isCreateAccountBaseOnCommitterEmail() { ChangeLogSet parent = getParent(); boolean createAccountBaseOnCommitterEmail = false; if (parent != null) { SCM scm = parent.getBuild().getProject().getScm(); if (scm instanceof GitSCM) { createAccountBaseOnCommitterEmail = ((GitSCM) parent.getBuild().getProject().getScm()). isCreateAccountBaseOnCommitterEmail(); } } return createAccountBaseOnCommitterEmail; }
public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException { SCM scm = getScm(); if (scm == null) { return true; // no SCM } FilePath workspace = build.getWorkspace(); workspace.mkdirs(); boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile); calcPollingBaseline(build, launcher, listener); return r; }
public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException { SCM scm = getScm(); if (scm == null) { return true; // no SCM } FilePath workspace = build.getWorkspace(); workspace.mkdirs(); boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile); calcPollingBaseline(build, launcher, listener); return r; }
public boolean cleanWorkspace() throws IOException, InterruptedException { checkPermission(BUILD); R b = getSomeBuildWithWorkspace(); FilePath ws = b != null ? b.getWorkspace() : null; if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) { ws.deleteRecursive(); return true; } else { // If we get here, that means the SCM blocked the workspace deletion. return false; } }