mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 04:52:20 +00:00
Making artifacts available for downloads.
This commit is contained in:
1 parent
f53bb92f94
commit
cee86fbb73
5 files changed
+105
-3
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.EnvVars;
|
||||
import hudson.maven.reporters.MavenArtifact;
|
||||
import hudson.maven.reporters.MavenArtifactRecord;
|
||||
import hudson.maven.reporters.SurefireArchiver;
|
||||
import hudson.slaves.WorkspaceList;
|
||||
@@ -184,6 +183,14 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about artifacts produced by Maven.
|
||||
*/
|
||||
@Exported
|
||||
public MavenArtifactRecord getMavenArtifacts() {
|
||||
return getAction(MavenArtifactRecord.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposes {@code MAVEN_OPTS} to forked processes.
|
||||
*
|
||||
|
||||
@@ -374,6 +374,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
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.
|
||||
* (when indivudual modules are built, a new ModuleSetBuild is not created,
|
||||
|
||||
@@ -31,7 +31,7 @@ import hudson.model.BuildListener;
|
||||
import hudson.model.FingerprintMap;
|
||||
import hudson.model.Hudson;
|
||||
|
||||
import org.apache.maven.RepositoryUtils;
|
||||
import hudson.util.HttpResponses;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
@@ -39,6 +39,8 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||
|
||||
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.ExportedBean;
|
||||
|
||||
@@ -46,6 +48,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -101,7 +104,7 @@ public final class MavenArtifact implements Serializable {
|
||||
*/
|
||||
@Exported
|
||||
public final String md5sum;
|
||||
|
||||
|
||||
public MavenArtifact(Artifact a) throws IOException {
|
||||
this.groupId = a.getGroupId();
|
||||
this.artifactId = a.getArtifactId();
|
||||
@@ -194,6 +197,15 @@ public final class MavenArtifact implements Serializable {
|
||||
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) {
|
||||
return build.getArtifactsDir().child(groupId).child(artifactId).child(version).child(fileName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<!--
|
||||
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>
|
||||
Reference in new issue
Block a user