Skip to end of metadata
Go to start of metadata

Plugin Information

View Maven Repository Server on the plugin site for more information.


This plug-in exposes project builds as a maven repository so the artifacts can be picked up by downstream builds or other systems.

Use in a Maven build pipeline

1. Add the following to the jenkins maven settings.xml file:

settings.xml
<profile>
   <id>upstream</id>
   <repositories>
      <repository>
         <id>upstream</id>
         <url>${env.Jenkins.Repository}</url>
         <releases>
             <enabled>true</enabled>
         </releases>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
      </repository>
    </repositories>
 <pluginRepositories>
    <pluginRepository>
          <id>upstream</id>
          <url>${env.Jenkins.Repository}</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
         </snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>
Add maven setting

Add -Pupstream to your maven 'goals and options' (e.g: -Pupstream clean install) to turn on the above profile.

Check the "Define Upstream Maven Repository" checkbox item

Set a specific project, or the project that caused this build.

Description

After installation, archived build artifacts of your Maven jobs will be available as a maven repository so that other tools or builds that understand maven repositories can use them directly, without having to upload them to a separate server first.

By Build
http://jenkins-server:port/plugin/repository/project/projectName/Build/buildNumber/repository

Thus an artifact from build 4 of project helloworld might be

http://jenkins-server:port/plugin/repository/project/helloworld/Build/4/repository/org/example/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.pom
By GIT SHA1

Alternatively, if your build was executed from source stored in a GIT repository, you can access it via the SHA1 id. The plugin will return the most recent successful build artifacts.

http://jenkins-server:port/plugin/repository/project/projectName/SHA1/buildSHA1/repository

Thus an artifact from build 4 of project helloworld might be

http://jenkins/plugin/repository/helloworld/SHA1/f9a6ccb7fa31b6d88cd4ce0554d46aa4f3850425/repository/org/example/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.pom

http://jenkins-server:port/plugin/repository/project/helloworld/SHA1/f9a6ccb7fa31b6d88cd4ce0554d46aa4f3850425/repository/org/example/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.pom

This feature could be used (with an appropriate script) to allow a developer who checks out a particular branch, to automatically sync his local repository with the correctly built artifacts stored in jenkins. You can access the build without the project name:

http://jenkins-server:port/plugin/repository/SHA1/buildSha1

Therefore you could sync your repository with something like the following:

wget -e robots=off -P ~/.m2/repository -np -r -nH --cut-dirs=4 http://jenkins:8080/plugin/repository/SHA1/`git rev-parse HEAD`/
All Builds

A repository containing all build artifacts is available at

http://jenkins-server:port/plugin/repository/everything

Chained Builds

The above examples return repositories containing just the artifacts from the particular build. You can get access to a repository that also contains any upstream resources by substituting 'repository' for 'repositoryChain'. E.g:

http://jenkins-server:port/plugin/repository/project/projectName/Build/buildNumber/repositoryChain

 

Care is needed due to aliasing of artifacts if you have multiple projects generating artifacts with the same coordinate with the 'everything' and 'repositoryChain' modes.

Version History

0.9

Various fixes for content-type rendering, maven-metadata.xml generation, checksums and snapshot versions.

0.6

* New UI extension to simplify jobs that need to point to specific (typically upstream) repositories
* The repository now supports WebDAV, so it can be browsed/connected to by WebDAV clients
* Ships with a tools repository containing a maven plugin. This plugin can be used to synchronise a local machine with artifacts contained in a build in Jenkins.

0.5

Introduce an extension point

0.4

Fix resolving artifacts with different canonicalNames (e.g pom files)

0.3

* pom.xml artifacts renamed to artifact-version.pom (canonicalName)
* don't expose part-built project repositories
* New top-level repository, like 'everything', called 'SHA1' (so developers can wget build repo without having to know Jenkins project name)
* Add tokens for token-macro plugin of ${REPOSITORY_UPSTREAM} and ${REPOSITORY_UPSTREAM} which calculate the correct upstream repository url for the build in progress (based on the upstream build).

0.2

Updates to include requested LastSuccessful and 'everything', and also chained job repositories. Slightly adjusted URL space to add room for the everything repository.

0.1

Initial Release

 

 

 

8 Comments

  1. Very nice idea which deserves to be extended: currently, using Maven with Jenkins, artifacts are uploaded from slaves to master and (deployed to) some Maven repositories. That consumes a lot of bandwidth, disk space and time.

    I guess the current behavior of the plugin makes its use complex to automate. But why not making the whole Jenkins server exposed as a unique Maven repository ? I mean being able to use http://jenkins/plugin/repository/org/example/helloworld/1.0-SNAPSHOT/helloworld-1.0-SNAPSHOT.pom with the "helloworld/Build/4/repository/" part.

    That way, it would be possible to automatically add Jenkins in the repositories list and any job would be able to retrieve its dependencies, through maven build, either from a remote repository, either directly from the latest job which successfully built the needed artifact.

    Anyway, nice idea !

  2. Really the missing link between jenkins and maven. We already drive an nexus repo in first dmz with internet access for oopensource and free source artifacts and as enterprise public maven repo. We wanted to drive another nexus server along with jenkins in second dmz (no internet access) which holds the enterprise product source artifacts for security reasons.

    What would be perfect for enterprise usage to have for every job a maven repo (release and snaphots) and access is granted via and new right on project/job level.Further to grant accecs with and without sources.

    THen access to all artifacts via one url, so yoi will find all artifacts of jobs u have maven repo read rights

    New Rights needed: Read Snaphots, Read Releases, Read sources

  3. I guess that this plugin requires that artifacts are archived for jobs?

    I ask because we have - for performance reasons - disabled the automatic artifact archiving for all our maven jobs.

  4. The plugin looks great but it does not create full HTML and/or set the correct mime type. This means in Safari you see.

    <H1>com.revolsys.open</H1><TABLE><TR><TD>Fri Feb 17 14:15:39 PST 2012</TD><TD>DIR</TD>
    <TD><A href='SHA1/'>SHA1</A></TD><TD></TD></TR><TR><TD>Fri Feb 17 14:15:39 PST 2012</TD>
    <TD>DIR</TD><TD><A href='Build/'>Build</A></TD><TD></TD></TR>
    <TR><TD>Fri Feb 17 14:15:39 PST 2012</TD><TD>DIR</TD><TD><A href='LastSuccessful/'>LastSuccessful</A></TD><TD></TD></TR></TABLE>
    
    

    Recommendation:

    1. Make all the tags in lower case
    2. Include the full html (e.g. <html><head><title>...</title><body>....</body></html>

    1. The same with chrome and ie on windows here

  5. Is there a way to add third party libraries to this repository? For example, jar files that don't exist in any maven repository like the oracle jdbc driver.

  6. Hi there,

    if anyone is using this plugin for dependency management and having troubles with Jenkins authentication, here is a working configuration you can add to your settings.xml to have access to the repository:

    <server>
        <id>SERVER_ID</id>
        <username>YOUR_USER</username>
        <password>YOUR_API_TOKEN</password>
        <configuration>
            <httpConfiguration>
                <all>
                    <usePreemptive>true</usePreemptive>
                </all>
            </httpConfiguration>
        </configuration>
    </server>