mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
check out and POM parsing is now done as a "build".
We probably need to touch UI as calling this a build is quite confusing. But one thing at a time... git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1974 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
89f76a6501
commit
cf6a5ad20b
8 files changed
+221
-282
No files matched your search
@@ -10,6 +10,7 @@ import hudson.model.Hudson;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.ItemGroup;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Node;
|
||||
import hudson.util.DescribableList;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
@@ -101,6 +102,14 @@ public final class MavenModule extends AbstractProject<MavenModule,MavenBuild> i
|
||||
return (MavenModuleSet)super.getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link MavenModule} uses the workspace of the {@link MavenModuleSet},
|
||||
* so it always needs to be built on the same slave as the parent.
|
||||
*/
|
||||
public Node getAssignedNode() {
|
||||
return getParent().getAssignedNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MavenBuild newBuild() throws IOException {
|
||||
MavenBuild lastBuild = new MavenBuild(this);
|
||||
|
||||
@@ -1,49 +1,29 @@
|
||||
package hudson.maven;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.Launcher;
|
||||
import hudson.Util;
|
||||
import hudson.model.AbstractItem;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.model.DirectoryBrowserSupport;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.DependencyGraph;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.ItemGroup;
|
||||
import hudson.model.Items;
|
||||
import hudson.model.JDK;
|
||||
import hudson.model.LargeText;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Project;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.model.TopLevelItem;
|
||||
import hudson.model.TopLevelItemDescriptor;
|
||||
import hudson.model.BuildableItem;
|
||||
import hudson.model.BuildAuthorizationToken;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.scm.NullSCM;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.scm.SCMS;
|
||||
import hudson.util.ByteBuffer;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import hudson.util.IOException2;
|
||||
import hudson.util.StreamTaskListener;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Group of {@link MavenModule}s.
|
||||
@@ -55,40 +35,12 @@ import java.util.Map;
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class MavenModuleSet extends AbstractItem implements TopLevelItem, BuildableItem, ItemGroup<MavenModule> {
|
||||
public class MavenModuleSet extends AbstractProject<MavenModuleSet,MavenModuleSetBuild> implements TopLevelItem, ItemGroup<MavenModule> {
|
||||
/**
|
||||
* All {@link MavenModule}s, keyed by their {@link MavenModule#getModuleName()} module name}s.
|
||||
*/
|
||||
transient /*final*/ Map<ModuleName,MavenModule> modules = new CopyOnWriteMap.Tree<ModuleName,MavenModule>();
|
||||
|
||||
private SCM scm = new NullSCM();
|
||||
|
||||
/**
|
||||
* Identifies {@link JDK} to be used.
|
||||
* Null if no explicit configuration is required.
|
||||
*
|
||||
* <p>
|
||||
* Can't store {@link JDK} directly because {@link Hudson} and {@link Project}
|
||||
* are saved independently.
|
||||
*
|
||||
* @see Hudson#getJDK(String)
|
||||
*/
|
||||
private String jdk;
|
||||
|
||||
/**
|
||||
* True to suspend any new builds in this module set.
|
||||
*/
|
||||
private boolean disabled;
|
||||
|
||||
/**
|
||||
* If this project is configured to be only built on a certain node,
|
||||
* this value will be set to that node. Empty string to indicate
|
||||
* affinity to the master, and null to indicate free-roam.
|
||||
*/
|
||||
private String assignedNode;
|
||||
|
||||
private BuildAuthorizationToken authToken;
|
||||
|
||||
public MavenModuleSet(String name) {
|
||||
super(Hudson.getInstance(),name);
|
||||
}
|
||||
@@ -102,36 +54,6 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, Builda
|
||||
return Hudson.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this project is configured to be always built on this node,
|
||||
* return that {@link Node}. Otherwise null.
|
||||
*/
|
||||
public Node getAssignedNode() {
|
||||
return Hudson.getInstance();
|
||||
// TODO
|
||||
//if(assignedNode==null)
|
||||
// return null;
|
||||
//if(assignedNode.equals(""))
|
||||
// return Hudson.getInstance();
|
||||
//return Hudson.getInstance().getSlave(assignedNode);
|
||||
}
|
||||
|
||||
public SCM getScm() {
|
||||
return scm;
|
||||
}
|
||||
|
||||
public void setScm(SCM scm) {
|
||||
this.scm = scm;
|
||||
}
|
||||
|
||||
public JDK getJDK() {
|
||||
return getParent().getJDK(jdk);
|
||||
}
|
||||
|
||||
public synchronized void setJDK(JDK jdk) throws IOException {
|
||||
this.jdk = jdk.getName();
|
||||
}
|
||||
|
||||
public Collection<MavenModule> getItems() {
|
||||
return modules.values();
|
||||
}
|
||||
@@ -158,8 +80,10 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, Builda
|
||||
return new File(new File(getRootDir(),"modules"),child.getModuleName().toFileSystemName());
|
||||
}
|
||||
|
||||
public Collection<MavenModule> getAllJobs() {
|
||||
return getItems();
|
||||
public Collection<Job> getAllJobs() {
|
||||
Set<Job> jobs = new HashSet<Job>(getItems());
|
||||
jobs.add(this);
|
||||
return jobs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,6 +94,23 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, Builda
|
||||
return Hudson.getInstance().getWorkspaceFor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MavenModuleSetBuild newBuild() throws IOException {
|
||||
MavenModuleSetBuild lastBuild = new MavenModuleSetBuild(this);
|
||||
builds.put(lastBuild);
|
||||
return lastBuild;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MavenModuleSetBuild loadBuild(File dir) throws IOException {
|
||||
return new MavenModuleSetBuild(this,dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFingerprintConfigured() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
|
||||
super.onLoad(parent, name);
|
||||
|
||||
@@ -192,6 +133,10 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, Builda
|
||||
}
|
||||
}
|
||||
|
||||
protected void buildDependencyGraph(DependencyGraph graph) {
|
||||
// no dependency for this.
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a workspace.
|
||||
*/
|
||||
@@ -199,197 +144,28 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, Builda
|
||||
try {
|
||||
FilePath workspace = getWorkspace();
|
||||
workspace.mkdirs();
|
||||
return scm.checkout(launcher, workspace, listener);
|
||||
return getScm().checkout(launcher, workspace, listener);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace(listener.fatalError("SCM check out aborted"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public BuildAuthorizationToken getAuthToken() {
|
||||
return authToken;
|
||||
}
|
||||
|
||||
public void scheduleBuild() {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private transient LargeText parsePomBuffer;
|
||||
private transient boolean parsePomSucceeded;
|
||||
|
||||
public static enum PomLinkMode {
|
||||
NONE, IN_PROGRESS, ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how to display 'parsing POM' link.
|
||||
*/
|
||||
public PomLinkMode getPomLinkMode() {
|
||||
LargeText buf = parsePomBuffer;
|
||||
if(buf==null) return PomLinkMode.NONE;
|
||||
if(!buf.isComplete()) return PomLinkMode.IN_PROGRESS;
|
||||
if(!parsePomSucceeded) return PomLinkMode.ERROR;
|
||||
return PomLinkMode.NONE;
|
||||
}
|
||||
|
||||
public void parsePOMs() {
|
||||
ByteBuffer buf = new ByteBuffer();
|
||||
parsePomBuffer = new LargeText(buf,false);
|
||||
parsePomSucceeded = false;
|
||||
final StreamTaskListener listener = new StreamTaskListener(buf);
|
||||
try {
|
||||
Launcher launcher = getAssignedNode().createLauncher(listener);
|
||||
listener.getLogger().println("Fetching up-to-date workspace");
|
||||
if(!checkout(launcher,listener))
|
||||
return;
|
||||
|
||||
listener.getLogger().println("Parsing POMs");
|
||||
// TODO: this needs to be moved to its own class since MavenModuleSet is not serializable
|
||||
List<PomInfo> poms = getWorkspace().act(new FileCallable<List<PomInfo>>() {
|
||||
public List<PomInfo> invoke(File ws, VirtualChannel channel) throws IOException {
|
||||
// TODO: this logic needs to be smarter
|
||||
File pom = new File(ws,"pom.xml");
|
||||
|
||||
try {
|
||||
MavenEmbedder embedder = MavenUtil.createEmbedder(listener);
|
||||
MavenProject mp = embedder.readProject(pom);
|
||||
Map<MavenProject,String> relPath = new HashMap<MavenProject,String>();
|
||||
MavenUtil.resolveModules(embedder,mp,"",relPath);
|
||||
|
||||
List<PomInfo> infos = new ArrayList<PomInfo>();
|
||||
toPomInfo(mp,relPath,infos);
|
||||
return infos;
|
||||
} catch (MavenEmbedderException e) {
|
||||
// TODO: better error handling needed
|
||||
throw new IOException2(e);
|
||||
} catch (ProjectBuildingException e) {
|
||||
throw new IOException2(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void toPomInfo(MavenProject mp, Map<MavenProject,String> relPath, List<PomInfo> infos) {
|
||||
infos.add(new PomInfo(mp,relPath.get(mp)));
|
||||
for (MavenProject child : (List<MavenProject>)mp.getCollectedProjects())
|
||||
toPomInfo(child,relPath,infos);
|
||||
}
|
||||
});
|
||||
|
||||
synchronized(modules) {
|
||||
Map<ModuleName,MavenModule> old = new HashMap<ModuleName, MavenModule>(modules);
|
||||
|
||||
modules.clear();
|
||||
for (PomInfo pom : poms) {
|
||||
MavenModule mm = old.get(pom.name);
|
||||
if(mm!=null) {// found an existing matching module
|
||||
mm.reconfigure(pom);
|
||||
modules.put(pom.name,mm);
|
||||
} else {// this looks like a new module
|
||||
mm = new MavenModule(this,pom);
|
||||
modules.put(mm.getModuleName(),mm);
|
||||
}
|
||||
mm.save();
|
||||
}
|
||||
|
||||
// remaining modules are no longer active.
|
||||
old.keySet().removeAll(modules.keySet());
|
||||
for (MavenModule om : old.values())
|
||||
om.disable();
|
||||
modules.putAll(old);
|
||||
}
|
||||
|
||||
Hudson.getInstance().rebuildDependencyGraph();
|
||||
listener.getLogger().println("done");
|
||||
parsePomSucceeded = true;
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(listener.error("Failed to parse POMs"));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace(listener.error("Aborted"));
|
||||
} catch (RuntimeException e) {
|
||||
// bug in the code.
|
||||
e.printStackTrace(listener.error("Processing failed due to a bug in the code. Please report thus to users@hudson.dev.java.net"));
|
||||
throw e;
|
||||
}
|
||||
parsePomBuffer.markAsComplete();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Web methods
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* Triggers the POM parsing and eventually updates the list of {@link MavenModule}s under
|
||||
* this project.
|
||||
*/
|
||||
public void doStartParsePOM(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
parsePOMs();
|
||||
}
|
||||
}).start();
|
||||
rsp.sendRedirect(".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles incremental log output.
|
||||
*/
|
||||
public void doProgressiveParsePOMLog( StaplerRequest req, StaplerResponse rsp) throws IOException {
|
||||
if(parsePomBuffer==null)
|
||||
rsp.setStatus(HttpServletResponse.SC_OK);
|
||||
else
|
||||
parsePomBuffer.doProgressText(req,rsp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a new build command.
|
||||
*/
|
||||
public void doBuild( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
|
||||
BuildAuthorizationToken.startBuildIfAuthorized(authToken,this,req,rsp);
|
||||
}
|
||||
|
||||
public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
if(!Hudson.adminCheck(req,rsp))
|
||||
return;
|
||||
|
||||
try {
|
||||
disabled = req.getParameter("disable")!=null;
|
||||
jdk = req.getParameter("jdk");
|
||||
setScm(SCMS.parseSCM(req));
|
||||
authToken = BuildAuthorizationToken.create(req);
|
||||
|
||||
if(req.getParameter("hasSlaveAffinity")!=null) {
|
||||
assignedNode = Util.fixNull(req.getParameter("slave"));
|
||||
if(!assignedNode.equals("")) {
|
||||
if(Hudson.getInstance().getSlave(assignedNode)==null) {
|
||||
assignedNode = ""; // no such slave
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assignedNode = null;
|
||||
}
|
||||
} catch (FormException e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
super.doConfigSubmit(req,rsp);
|
||||
|
||||
save();
|
||||
// SCM setting might have changed. Reparse POMs.
|
||||
rsp.sendRedirect("./startParsePOM");
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves the workspace files.
|
||||
*/
|
||||
public void doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
|
||||
FilePath ws = getWorkspace();
|
||||
if(!ws.exists()) {
|
||||
// if there's no workspace, report a nice error message
|
||||
rsp.forward(this,"noWorkspace",req);
|
||||
} else {
|
||||
new DirectoryBrowserSupport(this).serveFile(req, rsp, ws, "folder.gif", true);
|
||||
}
|
||||
scheduleBuild();
|
||||
}
|
||||
|
||||
public TopLevelItemDescriptor getDescriptor() {
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package hudson.maven;
|
||||
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Build;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Result;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.util.IOException2;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link Build} for {@link MavenModuleSet}.
|
||||
*
|
||||
* <p>
|
||||
* A "build" of {@link MavenModuleSet} consists of:
|
||||
*
|
||||
* <ol>
|
||||
* <li>Update the workspace.
|
||||
* <li>Parse POMs
|
||||
* <li>Trigger module builds.
|
||||
* </ol>
|
||||
*
|
||||
* This object remembers the changelog and what {@link MavenBuild}s are done
|
||||
* on this.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,MavenModuleSetBuild> {
|
||||
|
||||
public MavenModuleSetBuild(MavenModuleSet job) throws IOException {
|
||||
super(job);
|
||||
}
|
||||
|
||||
MavenModuleSetBuild(MavenModuleSet project, File buildDir) throws IOException {
|
||||
super(project, buildDir);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
run(new RunnerImpl());
|
||||
}
|
||||
|
||||
public RangeSet getDownstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
return new RangeSet();
|
||||
}
|
||||
|
||||
public int getUpstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sole job of the {@link MavenModuleSet} build is to update SCM
|
||||
* and triggers module builds.
|
||||
*/
|
||||
private class RunnerImpl extends AbstractRunner {
|
||||
protected Result doRun(final BuildListener listener) throws Exception {
|
||||
try {
|
||||
listener.getLogger().println("Parsing POMs");
|
||||
// TODO: this needs to be moved to its own class since MavenModuleSet is not serializable
|
||||
List<PomInfo> poms = project.getWorkspace().act(new FileCallable<List<PomInfo>>() {
|
||||
public List<PomInfo> invoke(File ws, VirtualChannel channel) throws IOException {
|
||||
// TODO: this logic needs to be smarter
|
||||
File pom = new File(ws,"pom.xml");
|
||||
|
||||
try {
|
||||
MavenEmbedder embedder = MavenUtil.createEmbedder(listener);
|
||||
MavenProject mp = embedder.readProject(pom);
|
||||
Map<MavenProject,String> relPath = new HashMap<MavenProject,String>();
|
||||
MavenUtil.resolveModules(embedder,mp,"",relPath);
|
||||
|
||||
List<PomInfo> infos = new ArrayList<PomInfo>();
|
||||
toPomInfo(mp,relPath,infos);
|
||||
return infos;
|
||||
} catch (MavenEmbedderException e) {
|
||||
// TODO: better error handling needed
|
||||
throw new IOException2(e);
|
||||
} catch (ProjectBuildingException e) {
|
||||
throw new IOException2(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void toPomInfo(MavenProject mp, Map<MavenProject,String> relPath, List<PomInfo> infos) {
|
||||
infos.add(new PomInfo(mp,relPath.get(mp)));
|
||||
for (MavenProject child : (List<MavenProject>)mp.getCollectedProjects())
|
||||
toPomInfo(child,relPath,infos);
|
||||
}
|
||||
});
|
||||
|
||||
// update the module list
|
||||
Map<ModuleName,MavenModule> modules = project.modules;
|
||||
synchronized(modules) {
|
||||
Map<ModuleName,MavenModule> old = new HashMap<ModuleName, MavenModule>(modules);
|
||||
|
||||
modules.clear();
|
||||
for (PomInfo pom : poms) {
|
||||
MavenModule mm = old.get(pom.name);
|
||||
if(mm!=null) {// found an existing matching module
|
||||
mm.reconfigure(pom);
|
||||
modules.put(pom.name,mm);
|
||||
} else {// this looks like a new module
|
||||
mm = new MavenModule(project,pom);
|
||||
modules.put(mm.getModuleName(),mm);
|
||||
}
|
||||
mm.save();
|
||||
}
|
||||
|
||||
// remaining modules are no longer active.
|
||||
old.keySet().removeAll(modules.keySet());
|
||||
for (MavenModule om : old.values())
|
||||
om.disable();
|
||||
modules.putAll(old);
|
||||
}
|
||||
|
||||
Hudson.getInstance().rebuildDependencyGraph();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(listener.error("Failed to parse POMs"));
|
||||
return Result.FAILURE;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace(listener.error("Aborted"));
|
||||
return Result.FAILURE;
|
||||
} catch (RuntimeException e) {
|
||||
// bug in the code.
|
||||
e.printStackTrace(listener.error("Processing failed due to a bug in the code. Please report thus to users@hudson.dev.java.net"));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public void post(BuildListener listener) {
|
||||
// TODO: trigger module builds
|
||||
// select the right modules to build based on changelog
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
*/
|
||||
protected Launcher launcher;
|
||||
|
||||
public final Result run(BuildListener listener) throws Exception {
|
||||
public Result run(BuildListener listener) throws Exception {
|
||||
Node node = Executor.currentExecutor().getOwner().getNode();
|
||||
assert builtOn==null;
|
||||
builtOn = node.getNodeName();
|
||||
@@ -100,21 +100,19 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
if(node instanceof Slave)
|
||||
listener.getLogger().println("Building remotely on "+node.getNodeName());
|
||||
|
||||
if(!project.checkout(AbstractBuild.this,launcher,listener,new File(getRootDir(),"changelog.xml")))
|
||||
if(checkout(listener))
|
||||
return Result.FAILURE;
|
||||
|
||||
SCM scm = project.getScm();
|
||||
|
||||
AbstractBuild.this.scm = scm.createChangeLogParser();
|
||||
AbstractBuild.this.changeSet = AbstractBuild.this.calcChangeSet();
|
||||
|
||||
for (SCMListener l : Hudson.getInstance().getSCMListeners())
|
||||
l.onChangeLogParsed(AbstractBuild.this,listener,changeSet);
|
||||
|
||||
Result result = doRun(listener);
|
||||
if(result!=null)
|
||||
return result; // abort here
|
||||
|
||||
createLastSuccessfulLink(listener);
|
||||
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void createLastSuccessfulLink(BuildListener listener) {
|
||||
if(!isWindows()) {
|
||||
try {
|
||||
// ignore a failure.
|
||||
@@ -132,8 +130,20 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
e.printStackTrace( log );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.SUCCESS;
|
||||
private boolean checkout(BuildListener listener) throws Exception {
|
||||
if(!project.checkout(AbstractBuild.this,launcher,listener,new File(getRootDir(),"changelog.xml")))
|
||||
return true;
|
||||
|
||||
SCM scm = project.getScm();
|
||||
|
||||
AbstractBuild.this.scm = scm.createChangeLogParser();
|
||||
AbstractBuild.this.changeSet = AbstractBuild.this.calcChangeSet();
|
||||
|
||||
for (SCMListener l : Hudson.getInstance().getSCMListeners())
|
||||
l.onChangeLogParsed(AbstractBuild.this,listener,changeSet);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,10 +35,10 @@ import java.awt.Paint;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
/**
|
||||
@@ -149,12 +149,7 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
|
||||
this.logRotator = logRotator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method always return a singleton set.
|
||||
* Calling this method from {@link Job} is pointless.
|
||||
*/
|
||||
public Set<Job> getAllJobs() {
|
||||
public Collection<? extends Job> getAllJobs() {
|
||||
return Collections.<Job>singleton(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user