Repository Management with Nexus

11.3. Configuring your Project for Deployment

Once Nexus is configured to receive artifacts in the staging suite as documented in Section 11.2, “Configuring the Nexus Staging Suite”, you will have to update your project build configuration to deploy to the staging suite.

The preferred way to do this is to take advantage of the features provided by the Nexus Staging Maven Plugin or the Nexus Staging Ant Tasks as documented in Section 11.3.1, “Deployment with the Nexus Staging Maven Plugin” and Section 11.3.2, “Deployment with the Nexus Staging Ant Tasks”.

If you need to continue to use the Maven Deploy Plugin you can read about using it with the Nexus Staging Suite in Section 11.3.3, “Deployment with the Maven Deploy Plugin”.

With all tools you can use the manual upload of your artifacts documented in Section 11.3.4, “Manually Uploading a Staged Deployment in Nexus”.

11.3.1. Deployment with the Nexus Staging Maven Plugin

The Nexus Staging Maven Plugin is a Nexus specific and more powerful replacement for the Maven Deploy Plugin with a number of features specifically geared towards usage with the Nexus Staging Suite. The simplest usage can be configured by adding it to the project build plugins section as an extension:

<build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.plugins</groupId>
      <artifactId>nexus-staging-maven-plugin</artifactId>
      <version>1.6.0</version>
      <extensions>true</extensions>
      <configuration>
        <serverId>local-nexus</serverId>
        <nexusUrl>http://localhost:8081/nexus/</nexusUrl>
      </configuration>
    </plugin>
[Note]

It is important to use a version of the plugin that is compatible with your Nexus server. Version 1.2 is compatible with Nexus 2.3, Version 1.4.4 is compatible with Nexus 2.4, Version 1.4.8 is compatible with Nexus 2.5 and 2.6. 1.5 and 1.6 can be used for Nexus 2.7 and 2.8. The latest version of the plugin available is always compatible with the latest available version of Nexus. Try to use the newest possible plugin version to take advantage of any available improvements.

Following Maven best practices the version should be pulled out into a pluginManagement section in a company POM or parent POM.

This configuration works only in Maven 3 and automatically replaces the deploy goal invocation of the Maven Deploy Plugin in the deploy Maven lifecycle phase with the deploy goal invocation of the Nexus Staging Maven Plugin.

The minimal required configuration parameters for the Nexus Staging Maven Plugin are:

serverId
the id of the server element in settings.xml from which the user credentials for accessing Nexus should be retrieved
nexusUrl
the base URL at which the Nexus server to be used for staging is available

With this configuration the Nexus Staging Maven Plugin will stage the artifacts locally and connect to Nexus. Nexus will try to determine the appropriate Staging Profile by matching the artifact path with any repository targets configured with staging profiles with an activated implicit profile selection strategy. If an appropriate staging profile is found a staging repository is created on the fly and the artifacts are deployed into it. If no profile is found the upload will fail.

To successfully deploy to your Nexus instance, you will need to update your Maven Settings with the credentials for the deployment user. These credentials are stored in the Maven Settings file in ~/.m2/settings.xml.

To add these credentials, add the following element to the servers element in your ~/.m2/settings.xml file as shown in Listing deployment credentials in Maven Settings.

Listing deployment credentials in Maven Settings. 

<settings>
  ...
  <servers>
    ...
    <server>
      <id>nexus</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
  </servers>
  ...
</settings>

Note that the server identifier listed in Listing deployment credentials in Maven Settings should match the serverId parameter you are passing to the Nexus Staging Maven Plugin and in the example contains the default password for the Nexus deployment user - deployment123. You should change this password to match the deployment password for your Nexus installation.

If more control is desired over when the plugins deploy goal is activated or if Maven 2 is used, you have to explicitly deactivate the Maven Deploy Plugin and replace the Maven Deploy Plugin invocation with the Nexus Staging Maven Plugin like visible in in Usage of Nexus Staging Maven Plugin for Maven 2.

Usage of Nexus Staging Maven Plugin for Maven 2. 

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.sonatype.plugins</groupId>
      <artifactId>nexus-staging-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>default-deploy</id>
          <phase>deploy</phase>
          <goals>
            <goal>deploy</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <serverId>local-nexus</serverId>
        <nexusUrl>http://localhost:8081/nexus/</nexusUrl>
        <!-- explicit matching using the staging profile id -->
        <stagingProfileId>129341e09f2ee275</stagingProfileId>
      </configuration>
    </plugin>
...

The implicit matching relies on the setup of repository targets as well as the correct order of staging profiles and is therefore an error prone approach when many staging profiles are in use.

The preferred way to work in this sceneario is to change the profile selection strategy on all staging profiles to explicit only and pass the staging profile id to the Nexus Staging Maven Plugin using the stagingProfileId configuration parameter as documented above. A full example pom.xml for deployment of snapshot as well as release builds with the Nexus Staging Maven Plugin using explicit matching for the staging profile and locally staged builds and atomic uploads is available in Full example pom.xml for Nexus Staging Maven Plugin usage.

Full example pom.xml for Nexus Staging Maven Plugin usage. 

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.sonatype.training.nxs301</groupId>
  <artifactId>explicit-staging-example</artifactId>
  <version>1.0.0</version>

  <distributionManagement>
    <snapshotRepository>
    <id>nexus-snapshots</id>
    <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.5.1</version>
        <extensions>true</extensions>
        <configuration>
              <serverId>nexus-releases</serverId>
          <nexusUrl>http://localhost:8081/nexus/</nexusUrl>
          <!-- update this to the correct id! -->
          <stagingProfileId>1296f79efe04a4d0</stagingProfileId>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

In order to deploy project artifacts to Nexus with the above setup you would invoke a build with

mvn clean deploy

The build will locally stage the artifacts for deployment in target/nexus-staging, on the console and create a closed staging repository in Nexus holding the build artifacts. This execution of the deploy goal of the Nexus Staging Maven Plugin performs the following actions:

  • the artifacts are staged locally,
  • a staging profile is selected either implicitly or explicitly
  • a staging repository is either created on the fly if needed or just selected
  • an atomic upload to the staging repository is performed
  • and the staging repository is closed (or dropped if upload fails)

The log of a successful deployment would look similar to this:

[INFO] --- nexus-staging-maven-plugin:1.1.1:deploy (injected-nexus-deploy) @ staging-example ---
[INFO] Using server credentials with ID="nexus-releases" from Maven settings.
[INFO] Preparing staging against Nexus on URL http://localhost:8081/nexus/
[INFO]  * Remote Nexus reported itself as version 2.2.1 and edition "Professional"
[INFO]  * Using staging profile ID "12a1656609231352" (matched by Nexus).
[INFO] Staging locally (stagingDirectory=
"/Users/manfred/dev/explicit-staging-example/target/nexus-staging/12a1656609231352")...
Uploading: file: ... explicit-staging-example-1.0.0.jar
Uploaded: file: ... explicit-staging-example-1.0.0.jar (4 KB at 1051.1 KB/sec)
Uploading: file: ... explicit-staging-example-1.0.0.pom
Uploaded: file: ... explicit-staging-example-1.0.0.pom (4 KB at 656.2 KB/sec)
Downloading: file: ...maven-metadata.xml
Uploading: file: ...maven-metadata.xml
Uploaded: file: ... maven-metadata.xml (322 B at 157.2 KB/sec)
[INFO] Staging remotely...
[INFO] Uploading locally staged directory: 12a1656609231352
[INFO] Performing staging against Nexus on URL http://localhost:8081/nexus/
[INFO]  * Remote Nexus reported itself as version 2.2.1 and edition "Professional"
[INFO]  * Created staging repository with ID "test-002",
applied tags: {javaVersion=1.6.0_37, localUsername=manfred}
[INFO]  * Uploading locally staged artifacts to:
http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/test-002
[INFO]  * Upload of locally staged artifacts done.
[INFO]  * Closing staging repository with ID "test-002".
[INFO] Finished staging against Nexus with success.

Failures are accompanied by error reports that reveal further details:

[ERROR] Error while trying to close staging repository with ID "test-003".
[ERROR]
[ERROR] Nexus Staging Rules Failure Report
[ERROR] ==================================
[ERROR]
[ERROR] Repository "Test-003 (u:admin, a:127.0.0.1)" (id=n/a) failures
[ERROR]   Rule "RepositoryWritePolicy" failures
[ERROR]     * Artifact updating: Repository ='releases:Releases' does
not allow updating
artifact='/com/sonatype/training/nexus/explicit-staging-example/t1.0.0/staging-example-1.0.0.jar'
[ERROR]     * Artifact updating: Repository ='releases:Releases' does
not allow updating
artifact='/com/sonatype/training/nexus/explicit-staging-example/1.0.0/staging-example-1.0.0.pom'
[ERROR]
[ERROR]

If the configuration parameter skipStagingRepositoryClose set to true is passed to the plugin execution, the remote staging repository will not be closed.

Instead of Nexus creating a staging repository based on the implicit or explicit staging profile selection, you can explicitly configure the staging repository to use by providing the staging repository name as value of the stagingRepositoryId configuration property via the plugin configuration or command line invocation.

The identifier of a staging repository can be determined by looking at the name column in the list of staging repositories. The name column used the capitalized id and adds the username and address the staging was deployed from in brackets. For example a name could be Test-003 (u: admin, a: 127.0.0.1). The ID of this staging repository is test-003.

Together with skipping the closing of the repository using skipStagingRepositoryClose it is possible to get multiple builds to deploy to the same staging repository and therefore have a number of artifacts go through the staging workflow together. An alternative to this approach would be to create an aggregating project that assembles all artifacts together e.g., in an assembly and then use this project for staging.

Finally to override all staging you can define the full repository URL to deploy to with the deployUrl configuration parameter e.g.

http://localhost:8081/nexus/content/repositories/releases/

This would cause any staging to be skipped and a straight upload of the artifacts to the repository to occur.

As part of the configuration section for the plugin you can define tags with arbitrary key and value names. For example you could create a tag with key localUsername and a value of the current user picked up from the USER environment variable:

...
<configuration>
...
  <tags>
    <localUsername>${env.USER}</localUsername>
    <javaVersion>${java.version}</javaVersion>
  </tags>
...

Once artifacts are released these tags are transformed into attributes stored along the artifacts in the release repository and can be accessed via the REST interface and therefore any plugin and user interface integration.

In addition to the above documented configuration options that determine the behvaiour of the Nexus Staging Maven Plugin, further configuration can be provided with the following parameters:

altStagingDirectory
defaulting to target/nexus-staging you can set the property to set a different folder for the local staging
description
allows you to provide a description for the staging repository action like close or drop carried out as part of the plugin execution. The description will then be used in any notification just like a description provided in the user interface.
keepStagingRepositoryOnFailure
setting this flag to true will cause the plugin to skip any clean up operations like dropping a staging repository for failed uploads, by default these clean up operations occur
keepStagingRepositoryOnCloseRuleFailure
with the default setting of false the Nexus Staging Maven Plugin will drop the created staging repository if any staging rule violation occurs. If this flag is set to true, it will not drop the staging repository. This allows you to inspect the deployed components in order to figure out why a rule failed causing the staging failure.
skipStagingRepositoryClose
set this to true to turn off the automatic closing of a staging repository after deployment
skipNexusStagingDeployMojo
set to false by default this flag will cause to skip any execution of the deploy goal of the plugin when set to true similar to maven.deploy.skip
skipStaging
set to false by default this flag will cause to skip any execution of the plugin when set to true
skipRemoteStaging
if this flag is set to true any step related to remote staging will be skipped and only local staging will be performed, the default setting is false
skipLocalStaging
by default set to true causes the Nexus Staging Maven Plugin to use local staging, setting this parameter to false turns off local staging, which emulates the immediate upload as performed by the Maven Deploy Plugin
autoReleaseAfterClose
if you set this flag to true, the staging repository will be closed and, following a successful validation of all staging rules including potential Sonatype CLM based validation, released. By default this property is set to false. Changing it to true can be a useful setup for continuous integration server based releases.
stagingProgressTimeoutMinutes
defaulting to 5 minutes, this configuration allows you to set the timeout for staging operations. Changes are most often required for complex staging operations involving custom staging rules or Sonatype CLM integration.
stagingProgressPauseDurationSeconds
the default of 3 seconds can be changed if larger pauses between progress polls for staging operations are desired.

With skipRemoteStaging set to true, only the local staging happens. This local staging can then be picked up for the remote staging and closing by running the deploy-staged goal of the plugin explicitly like this

mvn nexus-staging:deploy-staged

Besides the default deploy goal the Nexus Staging Maven Plugin supports a number of additional goals. By configuring executions of the goals as part of your POM or manually invoking them further automation of a staged release process can be achieved.

deploy-staged
perform full staging deployment workflow for a locally staged project e.g., with the artifacts in target/nexus-staging
deploy-staged-repository
perform an upload of a repository from the local filesystem to a staging repository.
close
close the staging repository for current context
drop
drop the staging repository for current context
release
release the staging repository for current context
promote
promote the staging repository for the current context

Closing, dropping and releasing the staging repository using the goals relies on content of a local staging folder .

Promoting additionally needs the build promotion profile name passed in via the buildPromotionProfileId configuration parameter.

The deploy-staged-repository goal can be used to stage a repository. Typically a local repository is created with an invocation of the deploy similar to

mvn deploy -DaltDeploymentRepository=local::default::file://path

To deploy this file system repository with the goal, you have to provide the path to this repository with the repositoryDirectory parameter as well as nexusUrl, serverId and stagingProfileId . Optionally you can configure the repository to stage into with stagingRepositoryId. This aggregated command is then be run outside any specific Maven project.

While the above goals need the context of a project with configuration for the Nexus Staging Plugin in the POM file, it is possible to execute staging repository related tasks without a project as well. The Nexus Staging Maven Plugin offers remote-control goals to control staging in Nexus:

rc-close
close a specified staging repository
rc-drop
drop a specified staging repository
rc-release
release a specified staging repository
rc-promote
promote a specified staging repository
rc-list
list all staging repositories

When invoking these goals outside a project context you need to have the Nexus Staging Maven Plugin groupId specified as a pluginGroup in your settings.xml:

 <pluginGroups>
       <pluginGroup>org.sonatype.plugins</pluginGroup>
 </pluginGroups>

In addition you need to specify all parameters on the command line as properties passed in via -Dkey=value.

At a minimum the required parameters serverId and nexusUrl have to be specified:

 mvn nexus-staging:rc-close -DserverId=local-nexus -DnexusUrl=http://localhost:8081/nexus

Depending on the goal you will have to configure the staging repositories you want to close, drop or release with

 -DstagingRepositoryId=repo-001,repo-002

and you can also supply a description like this

-Ddescription="Dropping since QA of issue 123 failed"

For promoting you need to add the required parameter that specifies the build promotion profile identifier:

-DbuildPromotionProfileId=12a25eabf8c8b3f2

A successful remote control drop would be logged in the command line similar to this

— nexus-staging-maven-plugin:1.2:rc-drop (default-cli) @ standalone-pom —
[INFO] Connecting to Nexus...
[INFO] Using server credentials with ID="nexus-releases" from Maven settings.
[INFO] RC-Dropping staging repository with IDs=[test-003]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

An example usage of the rc-list goal with output is

$mvn nexus-staging:rc-list -DnexusUrl=http://localhost:8081/nexus
-DserverId=nexus
...
[INFO] --- nexus-staging-maven-plugin:1.5.1:rc-list (default-cli) @ standalone-pom ---
[INFO] Connecting to Nexus...
[INFO] Using server credentials with ID="nexus" from Maven settings.
[INFO] Getting list of available staging repositories...
[INFO]
[INFO] ID                   State    Description
[INFO] example_release_profile-1000 OPEN     Implicitly created (auto
staging).
...
[Warning]

The Nexus Maven Plugin in versions earlier than 2.1.0 had goals to work with staging repositories. These goals have been deprecated in favour of the remote control goals of the Nexus Staging Maven Plugin.

11.3.2. Deployment with the Nexus Staging Ant Tasks

The Nexus Staging Ant Tasks provide equivalent features to the Nexus Staging Maven Plugin for Apache Ant users covering all use cases for interacting with the Nexus Staging Suite.

To use the Ant tasks in your Ant build file you need to download the complete jar with the included dependencies. You can find it at the Central Repository. Simply search for nexus-staging-ant-tasks and download the jar file with the uber classifier e.g., nexus-staging-ant-tasks-1.0-uber.jar.

After downloading, put the jar file somewhere in your project or in your system so you can add it to the classpath in your build file with a task definition. In the following example the jar file is placed in a tasks folder within the project.

<taskdef uri="antlib:org.sonatype.nexus.ant.staging"
         resource="org/sonatype/nexus/ant/staging/antlib.xml">
  <classpath>
    <fileset dir="tasks" includes="nexus-staging-ant-tasks-*uber.jar" />
  </classpath>
</taskdef>

To enable the tasks in your build file using a shortcut for the namespace, e.g., staging, you have to add it to the project node:

<project xmlns:staging="antlib:org.sonatype.nexus.ant.staging" ...>

The deployment related information for your project is captured in a nexusStagingInfo section in your build file that contains all the necessary configuration.

<staging:nexusStagingInfo id="target-nexus"
    stagingDirectory="target/local-staging">
  <staging:projectInfo groupId="org.sonatype.nexus.ant"
      artifactId="nexus-staging-ant-tasks"
      version="1.0" />
  <staging:connectionInfo
      baseUrl="http://localhost:8081/nexus">
    <staging:authentication
      username="deployment"
      password="deployment123" />
  </staging:connectionInfo>
</staging:nexusStagingInfo>
nexusStagingInfo:id
the identifier that allows you to reference the staging information in the Ant build file
stagingInfo:stagingDirectory
the local staging directory, a place where local staging will happen. Ensure that this directory is cleaned up by a clean task or alike, if any.
projectInfo
the project information targetting a staging profile. This can be done explicitly with the stagingProfileId or implicitly with groupId, artifactId and version. stagingRepositoryId can also be part of projectInfo identifying a staging repository for interaction
connectionInfo:baseUrl
the base URL of the Nexus server you want to deploy to and interact with

If necessary the connection Info can have a nested proxy section

<staging:proxy
    host="proxy.mycorp.com"
    port="8080">
  <staging:authentication
      username="proxyUser"
      password="proxySecret" />
</staging:proxy>

With the above setup you are ready to add a deploy target to your build file that stages the artifacts locally as well as remotely and closes the staging repository.

<target name="deploy" description="Deploy: Local and Remote Staging">

  <staging:stageLocally>
    <staging:nexusStagingInfo
        refid="target-nexus" />
      <fileset dir="target/local-repo"
        includes="**/*.*" />
    </staging:stageLocally>

  <staging:stageRemotely>
    <staging:nexusStagingInfo
        refid="target-nexus" />
  </staging:stageRemotely>

</target>

Similarily you can create a target that releases the staged artifacts by adding the releaseStagingRepository task to the end of the target:

<staging:releaseStagingRepository>
  <staging:nexusStagingInfo
      refid="target-nexus" />
</staging:releaseStagingRepository>

The stageLocally task takes a fileset as configuration. The stageRemotely task has additional configuration options

keepStagingRepositoryOnFailure
set to true this causes the remote staging repository to be kept rather than deleted in case of a failed upload, default setting is false
skipStagingRepositoryClose
by default a staging repository is automatically closed, setting this parameter to true will cause the staging repository to remain open

In addition to the tasks for local and remote staging the Nexus Staging Ant Tasks includes tasks for closing, dropping, releasing and promoting a staging repository:

  • closeStagingRepository
  • dropStagingRepository
  • releaseStagingRepository
  • promoteStagingRepository

All these tasks take the context information from the local staging directory or from the optional parameter stagingRepositoryId. The task to promote a repository has the additional, mandatory attribute buildPromotionProfileId to specify the build promotion profile to promote.

The timing of the task operation can be affected by the following configuration parameters:

stagingProgressTimeoutMinutes
defaulting to 5 minutes, this configuration allows you to set the timeout for staging operations. Changes are most often required for complex staging operations involving custom staging rules or Sonatype CLM integration.
stagingProgressPauseDurationSeconds
the default of 3 seconds can be changed if larger pauses between progress polls for staging operations are desired.

11.3.3. Deployment with the Maven Deploy Plugin

When using the Maven Deploy Plugin with the Nexus Staging Suite, you rely on implicit matching of the artifacts against a staging profile based on a repository target definition.

To deploy a staged release, a developer needs to deploy to the staging URL. To configure a project to deploy to the Staging URL, add the a distributionManagement element to your project’s POM.

Listing the Staging URL in distributionManagement. 

<project xmlns="http://maven.apache.org/POM/4.0.0"
...
  <distributionManagement>
    <repository>
      <id>nexus</id>
      <name>Nexus Staging Repo</name>
      <url>http://localhost:8081/nexus/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>
...
</project>

This configuration element, distributionManagement, defines the repository to which our deployment will be made. It references the Staging Suite’s Staging URL: http://localhost:8081/nexus/service/local/staging/deploy/maven2

This URL acts as a something of a virtual repository to be published to. If an artifact being published matches one of the Repository Targets in a Staging Profile, that Staging Profile is "activated" and a temporary Staging Repository is created.

Once the sample project’s distributionManagement has been set to point at the Nexus Staging URL and your deployment credentials are updated in your ~/.m2/settings.xml file, you can deploy to the Staging URL. To do this, run mvn deploy

$ mvn deploy
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building staging-test
[INFO]    task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: /private/tmp/staging-test/target/surefire-reports

...
[INFO] [jar:jar]
[INFO] [install:install]
[INFO] Installing /private/tmp/staging-test/target/staging-test-1.0.jar to \
~/.m2/repository/com/sonatype/sample/staging-test/1.0/staging-test-1.0.jar
[INFO] [deploy:deploy]
altDeploymentRepository = null
Uploading: http://localhost:8081/nexus/service/local/staging/deploy/maven2/\
com/sonatype/sample/staging-test/1.0/staging-test-1.0.jar
2K uploaded
[INFO] Uploading project information for staging-test 1.0
[INFO] Retrieving previous metadata from nexus
[INFO] repository metadata for: 'artifact com.sonatype.sample:staging-test'
could not be found on repository: nexus, so will be created
[INFO] Uploading repository metadata for: 'artifact com.sonatype.sample:staging-test'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

If the Staging Suite is configured correctly, any deployment to the staging URL matching in a repository target configured for a stating profile should be intercepted by the Staging Suite and placed in a temporary staging repository. Deployment with the Maven Deploy Plugin will not automatically close the staging repository. Closing the staging repository has to be done with the Nexus user interface or the Nexus Staging Maven Plugin. Once this repository has been closed, it will be made available in the Target Group you selected when you configured the Staging Profile.

11.3.4. Manually Uploading a Staged Deployment in Nexus

You can also upload a staged deployment via the Nexus interface. To upload a staged deployment, select Staging Upload from the Nexus menu. Clicking Staging Upload will show the panel shown in Figure 11.10, “Uploading a Staged Deployment in Nexus”.

figs/web/staging_artifact-upload.png

Figure 11.10. Uploading a Staged Deployment in Nexus


To upload an artifact, click on Select Artifact(s) for Upload… and select an artifacts from the filesystem to upload. Once you have selected an artifact, you can modify the classifier and the extension before clicking on the Add Artifact button. Repeat this process to upload mutltiple artifacts for the same Group, Artficat and Version (GAV) coordinates like a jar, the pom and maybe a sources and javadoc jar in addition. Once you have added all the artifacts, you can then configure the source of the Group, Artifact, Version (GAV) parameters.

If the artifact you are uploading is a JAR file that was created by Maven it will already have POM information embedded in it, but if you are uploading a JAR from a vendor you will likely need to set the Group Identifier, Artifact Identifier, and Version manually. To do this, select GAV Parameters from the GAV Definition drop-down at the top of this form. Selecting GAV Parameters will expose a set of form fields which will let you set the Group, Artifact, Version, and Packaging of the artifacts being uploaded. If you would prefer to set the Group, Artifact, and Version from a POM file which was associated with the uploaded artifact, select From POM in the GAV Definition drop-down. Selecting From POM in this drop-down will expose a button labelled "Select POM to Upload". Once a POM file has been selected for upload, the name of the POM file will be displayed in the form field below this button.

The Staging Upload panel supports multiple artifacts with the same Group, Artifact, and Version identifiers. For example, if you need to upload multiple artifacts with different classifiers, you may do so by clicking on Select Artifact(s) for Upload and Add Artifact multiple times. This interface also accepts an Artifact Bundle which is a JAR that contains more than one artifact, which is documented in more detail in Section 11.7, “Artifact Bundles”.

Once a staging artifact upload has been completely configured, click on Upload Artifact(s) button to begin the upload process. Nexus will upload the artifacts to the Staging URL which will trigger any staging profiles that are activated by the upload by explicity matching using the repository targets configured with the staging profiles. If a staging profile is activated, a new staging repository will be created and can be managed using the procedures outlined in Section 11.4, “Managing Staging Repositories in Nexus”.