This Orb is published to sonatype/nexus-platform-orb
. See the orb page for the latest version.
See the demo on the Sonatype Community site for a working example.
This .circleci/config.yml
is copied from CircleCI's examples here: https://circleci.com/docs/2.0/language-java/
version: 2 # use CircleCI 2.0
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/circleci-demo-java-spring # directory where steps will run
docker: # run the steps with Docker
- image: circleci/openjdk:8-jdk-browsers # ...with this image as the primary container; this is where all `steps` will run
steps: # a collection of executable commands
- checkout # check out source code to working directory
- restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn dependency:go-offline # gets the project dependencies
- save_cache: # saves the project dependencies
paths:
- ~/.m2
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn package # run the actual tests
- store_test_results: # uploads the test metadata from the `target/surefire-reports` directory so that it can show up in the CircleCI dashboard.
path: target/surefire-reports
- store_artifacts: # store the uberjar as an artifact
path: target/demo-java-spring-0.0.1-SNAPSHOT.jar
# See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples
To add the CircleCi Nexus Repository Manager Orb add the first 2 lines of the following example to the beginning of
your .circleci/config.yml
and update the CircleCI version
to at least 2.1
.
orbs:
nexus-orb: sonatype/nexus-platform-orb@1.0.1
version: 2.1 # use CircleCI 2.1
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/circleci-demo-java-spring # directory where steps will run
docker: # run the steps with Docker
- image: circleci/openjdk:8-jdk-browsers # ...with this image as the primary container; this is where all `steps` will run
...
...
After we have imported the Orb into our build we can now call Nexus RM. To do this add the
following lines at the end of your .circleci/config.yml
...
...
workflows:
main:
jobs:
- build
- nexus-orb/nexusjob:
requires:
- build
After we have imported the Orb into our build we can now call Nexus RM. To do this add the
following lines at the end of your .circleci/config.yml
...
...
- store_artifacts: # store the uberjar as an artifact
path: target/demo-java-spring-0.0.1-SNAPSHOT.jar
# See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples
- nexus-orb/install
- nexus-orb/publish:
# add the following required variables to your CircleCI environment:
# NEXUS_RM_USER
# NEXUS_RM_PASSWORD
filename: "target/demo-java-spring-0.0.1-SNAPSHOT.jar" # or environment NEXUS_RM_FILENAME
attributes: "-CgroupId=com.example -CartifactId=myapp -Cversion=1.3 -Aextension=jar" # or NEXUS_RM_ATTRIBUTES
serverurl: "http://nexus.example.com/" # or environment NEXUS_RM_SERVERURL
This will install groovy and the Nexus client into your build system. You only need to run this once per build even if you publish multiple artifacts.
This will upload your artifacts to Nexus Repository Manager.
path
used in
the store_artifacts
step in the code example above.-C
and asset attributes
with -A
. This is passed directly to Nexus Repository Manger so many additional
attributes to the ones used in the example above can be used as well.username
, password
, and possibly serverurl
should not be hardcoded in your build files.
If you create a CircleCi context with the environment variables below you can remove them from
your .circleci/config.yml
file.
NEXUS_RM_USERNAME
NEXUS_RM_PASSWORD
NEXUS_RM_SERVERURL