Repository Connector Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID repository-connector Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.1.1 (archives)
Feb 28, 2015
1.509
token-macro (version:1.5.1)
Source Code
Issue Tracking
Pull Requests
Maintainer(s)
GitHub
Open Issues
Pull Requests
Dominik Bartholdi (id: imod)
Michael Rumpf (id: mrumpf)
Usage Installations 2014-May 892
2014-Jun 938
2014-Jul 1031
2014-Aug 1004
2014-Sep 1086
2014-Oct 1103
2014-Nov 1130
2014-Dec 1113
2015-Jan 1181
2015-Feb 1257
2015-Mar 1355
2015-Apr 1356

Repository Connector adds features around resolving artifacts from a Maven repository like Nexus or Artifactory.
When installing this plugin, you'll get an additional build parameter 'Maven Repository Artifact' and a build step 'Artifact Resolver', allowing you to select versions from a remote repository and to download the artifact.

The Respository Connector Plugin can be used for example to deploy artifacts to target servers and it uses the Sonatype's Aether API internally to resolve artifacts from a repository and to determine the sorting order of versions.

Usage

The build parameter 'Maven Repository Artifact' allows for easy version selection and the build step 'Artifact Resolver' lets you download the artifact from a Maven repository without the need to install Maven.

It is possible to use the version selection feature of this plugin alone and let a Maven POM do the artifact download, or you let Jenkins also do the download before a script is invoked. The way you use the plugin is completely up to you.

Using only the version selection feature makes sense when you have Maven installed anyway and you want to have all aspects of the artifact processing under version control (see Maven example below)

Version Selection

String Parameter

You can use a simple string build parameter (e.g. 'VERSION') to enter a version as free text:

  • 1.0.0 - a regular version
  • RELEASE - the latest release version
  • LATEST - the latest version, which is usually a SNAPSHOT version
  • [0-SNAPSHOT,) - a version range

This string parameter can be used in the later stages of the job by specifying the property ${VERSION}. It can even be used in the version field of the Artifact Resolver build step.

Maven Repository Artifact Parameter

The version selection feature is provided by the build parameter 'Maven Respository Artifact':

When you click on "Build with Parameters" you will see a drop-down box with all the versions that have been found in the Maven repository:

The special versions "LATEST" and "RELEASE" are added to the list where the latter is the default selection (new, not yet-released feature, see JENKINS-28323).

The selected version is passed in 2 properties to the build:

  • <groupId>.<artifactId>=<version> (e.g. "commons-collections.commons-collections=1.0.0")
  • <global-repo-name>=<version> (e.g. "central=1.0.0")

Artifact Resolver Build Step

The 'Artifact Resolver' build step allows you to download the specified artifact in a build step. The location where the artifact is downloaded to can be specified by the parameters "target directory" and "target filename":

For passing the parameter version use

${<groupId>.<artifactId>}

 Example

${commons-collections.commons-collections}

Global Configuration

The repositories to resolve the artifacts from, can be configured in Jenkins' global configuration section:

Example

The following Maven POM downloads the artifact, and passes the path to the artifact to a shell script for further processing. The shell script also gets an environment parameter which comes from a "Choice Paramater" to determine the target environment on which to deploy the artifact.

Example deployment POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.foobar.deploy.maven</groupId>
  <artifactId>maven-deploy-template</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Maven deployment template</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.foobar.templates</groupId>
      <artifactId>maventemplate-ear</artifactId>
      <version>${distversion}</version>
      <type>ear</type>
    </dependency>
  </dependencies>

  <scm>
    <connection>scm:git:https://yourgitserver/jenkins-deploy-job-maven.git</connection>
    <developerConnection>scm:git:https://yourgitserver/jenkins-deploy-job-maven.git</developerConnection>
  </scm>

  <ciManagement>
    <system>jenkins</system>
    <url>https://yourjenkinsserver/jenkins/</url>
  </ciManagement>

  <repositories>
    <repository>
      <id>project</id>
      <url>https://yourreposerver/nexus/content/groups/public/</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>project</id>
      <url>https://yourreposerver/nexus/content/groups/public/</url>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <configuration>
              <target>
                <!-- dump all available properties -->
                <echoproperties />
                <exec dir="." executable="cmd" osfamily="windows">
                  <arg value="/c"/>
                  <arg value="deploy.cmd ${maven.dependency.com.foobar.templates.maventemplate-ear.ear.path} ${environment} ${distversion}"/>
                </exec>
                <exec dir="." executable="/bin/bash" osfamily="unix">
                  <arg value="-c"/>
                  <arg value="./deploy.sh ${maven.dependency.com.foobar.templates.maventemplate-ear.ear.path} ${environment} ${distversion}"/>
                </exec>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
  </profiles>
</project>

NOTE: This is just a suggestion. Instead of forking a shell script, all the necessary steps could als be performed by the Antrun Maven plugin.

Help and Support

For Help and support please use the Jenkins Users mailing list.
The comment list below is not monitored.

Version History

1.1.2 (Not yet released)

1.1.1 (28. Feb 2015)

1.1.0 (2. Feb 2015)

1.0.1 (16. Aug. 2014)

1.0.0 (18. July 2014)

  • fix JENKINS-17541 target directory does not expand token macro parameters
  • integrate PR #3 (thanks to mrumpf!)
    • Sort the list of Maven repositories in the global configuration page
    • Added I18N and translated all help files and texts to german
    • Extracted the global configuration from the ArtifactResolver and moved it into the central class GlobalConfiguration
    • Added the version selection build parameter
    • When your ArtifactResolver build step and the build parameter is used in one job, the version, selected by the builld parameter overrides the version of the ArtifactResolver build step.
    • Added proxy support which makes the plugin usable in corporate environments

0.8.2 (18. Feb. 2012)

0.8.0 (18. Sep. 2011)

  • add support for variable resolving in configuration

0.7.0

  • update to aether 1.12 and fix a classloader issue

0.6.1

  • update to aether 1.11 and fix update policy issue

0.6

  • now supports to configure the repository update policy (for earch builder individually)

0.5

  • Inital

Labels

plugin-external plugin-external Delete
plugin-maven plugin-maven Delete
token-consumer token-consumer Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 25, 2011

    wolfgang haefelinger says:

    Why would I ever wish to download an artefact from a Maven repository as additio...

    Why would I ever wish to download an artefact from a Maven repository as additional build step? Perhaps when using Ant without Ivy? Nevertheless, the missing functionality is something urgently needed.

  2. Jul 07, 2011

    Andrew Morando says:

    Hi, I have a parameterized build and I wish to use the value of the parameter a...

    Hi,

    I have a parameterized build and I wish to use the value of the parameter as my "Version" when retrieving the artifact.

    e.g. I have defined a parameter called My_Version.  the user enters "1.0.1-SNAPSHOT"

    I have tried to use $My_Version, %My_Version% and many others, but nothing works.

    Is there a way to do this?

    Thank you.

    Andrew

    1. Mar 22, 2012

      Fernando Borrego Polo says:

      You can use ${VERSION}

      You can use ${VERSION}

  3. Mar 22, 2012

    Fernando Borrego Polo says:

    I just want to say I really love this plugin, we have artifacts generated by a t...

    I just want to say I really love this plugin, we have artifacts generated by a tool in a external server and we needed to download them as part of the deployment. The only thing I don't understand is what are the fields "Release update policy" and "Snapshot update policy" for.