提交 cee86fbb 编写于 作者: K Kohsuke Kawaguchi

Making artifacts available for downloads.

上级 f53bb92f
/*
* The MIT License
*
* Copyright (c) 2011, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.util;
import org.kohsuke.stapler.HttpResponse;
import java.io.File;
import java.io.IOException;
/**
* Various {@link HttpResponse} implementations.
*
* <p>
* This class extends from Stapler so that we can move implementations from here to Stapler periodically.
*
* @author Kohsuke Kawaguchi
*/
public class HttpResponses extends org.kohsuke.stapler.HttpResponses {
public static HttpResponse staticResource(File f) throws IOException {
return staticResource(f.toURI().toURL());
}
}
...@@ -25,7 +25,6 @@ package hudson.maven; ...@@ -25,7 +25,6 @@ package hudson.maven;
import hudson.FilePath; import hudson.FilePath;
import hudson.EnvVars; import hudson.EnvVars;
import hudson.maven.reporters.MavenArtifact;
import hudson.maven.reporters.MavenArtifactRecord; import hudson.maven.reporters.MavenArtifactRecord;
import hudson.maven.reporters.SurefireArchiver; import hudson.maven.reporters.SurefireArchiver;
import hudson.slaves.WorkspaceList; import hudson.slaves.WorkspaceList;
...@@ -184,6 +183,14 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> { ...@@ -184,6 +183,14 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
return true; return true;
} }
/**
* Information about artifacts produced by Maven.
*/
@Exported
public MavenArtifactRecord getMavenArtifacts() {
return getAction(MavenArtifactRecord.class);
}
/** /**
* Exposes {@code MAVEN_OPTS} to forked processes. * Exposes {@code MAVEN_OPTS} to forked processes.
* *
......
...@@ -374,6 +374,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven ...@@ -374,6 +374,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
return super.getDynamic(token,req,rsp); return super.getDynamic(token,req,rsp);
} }
/**
* Information about artifacts produced by Maven.
*/
@Exported
public MavenAggregatedArtifactRecord getMavenArtifacts() {
return getAction(MavenAggregatedArtifactRecord.class);
}
/** /**
* Computes the latest module builds that correspond to this build. * Computes the latest module builds that correspond to this build.
* (when indivudual modules are built, a new ModuleSetBuild is not created, * (when indivudual modules are built, a new ModuleSetBuild is not created,
......
...@@ -31,7 +31,7 @@ import hudson.model.BuildListener; ...@@ -31,7 +31,7 @@ import hudson.model.BuildListener;
import hudson.model.FingerprintMap; import hudson.model.FingerprintMap;
import hudson.model.Hudson; import hudson.model.Hudson;
import org.apache.maven.RepositoryUtils; import hudson.util.HttpResponses;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
...@@ -39,6 +39,8 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler; ...@@ -39,6 +39,8 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.ExportedBean;
...@@ -46,6 +48,7 @@ import java.io.File; ...@@ -46,6 +48,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.net.URL;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -101,7 +104,7 @@ public final class MavenArtifact implements Serializable { ...@@ -101,7 +104,7 @@ public final class MavenArtifact implements Serializable {
*/ */
@Exported @Exported
public final String md5sum; public final String md5sum;
public MavenArtifact(Artifact a) throws IOException { public MavenArtifact(Artifact a) throws IOException {
this.groupId = a.getGroupId(); this.groupId = a.getGroupId();
this.artifactId = a.getArtifactId(); this.artifactId = a.getArtifactId();
...@@ -194,6 +197,15 @@ public final class MavenArtifact implements Serializable { ...@@ -194,6 +197,15 @@ public final class MavenArtifact implements Serializable {
return f; return f;
} }
/**
* Serve the file.
*
* TODO: figure out how to make this URL more discoverable to the remote API.
*/
public HttpResponse doFile(@AncestorInPath MavenArtifactRecord parent) throws IOException {
return HttpResponses.staticResource(getFile(parent.parent));
}
private FilePath getArtifactArchivePath(MavenBuildProxy build, String groupId, String artifactId, String version) { private FilePath getArtifactArchivePath(MavenBuildProxy build, String groupId, String artifactId, String version) {
return build.getArtifactsDir().child(groupId).child(artifactId).child(version).child(fileName); return build.getArtifactsDir().child(groupId).child(artifactId).child(version).child(fileName);
} }
......
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Simon Wiest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<st:include page="/hudson/model/Run/_api.jelly" />
<h2>Artifact Information</h2>
<p>
<a href="../mavenArtifacts/api">Information about Maven artifacts produced by this</a> are exposed
in a machine readable form. This allows programmatic retrieval of the artifacts.
</p>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册