managing build artifacts with nexus

managing build artifacts with nexus

...on using sonatype nexus as a repository for software artifacts that have been created for internal consumption.

E2143258b0228b454fa4b63d406243f3?s=128

Avinash Chugh

August 13, 2013
Tweet

Transcript

  1. Managing build artifacts with Nexus ThoughtWorks

  2. Outline •The Repository Manager •Our use-case(s) •Component lifecycle •Nexus Setup

  3. A repository manager Stores and organizes binary software components (a.k.a

    jars) for use during your development lifecycle
  4. benefits •A destination for internally developed software artifacts •Share software

    components across other internally developed projects •Can proxy between the organization and public repositories •Faster and reliable builds •Greater visibility into your component library, and its usage
  5. our use case... ✓A destination for internally developed software artifacts

    ✓Share software components across other internally developed projects •Can proxy between the organization and public repositories ✓Faster and reliable builds •Greater visibility into your component library, and its usage
  6. our use case... •Host snapshot releases for components being developed

    •Host fixed versions of artifacts for environments that need specific releases •Segregate artifacts into different repositories (e.g. frameworks, apps, etc) •A local Maven repository
  7. Component lifecycle •Distributing Maven artifacts •Consuming components •Releasing the Maven

    artifacts
  8. Build lifecycle Clean Compile Test Package Verify Deploy

  9. A sample pom.xml <?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"> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> .... <distributionManagement> <snapshotRepository> <id>nexus-snapshots</id> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </project> mvn deploy (and that’s it)
  10. Consuming artifacts <?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">

    <groupId>com.foo.app</groupId> <artifactId>consumer-api</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> .... <repositories> <repository> <id>nexus</id> <name>Nexus</name> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </snapshots> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/snapshots/</url> <layout>default</layout> </repository> </repositories> ... 1. declare the maven repository
  11. Consuming artifacts .... <dependencies> <dependency> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> </dependency> ...

    </dependencies> </project> 3. mvn compile (and that’s it) 2. declare the jar- dependency 2. declare the jar- dependency
  12. Releasing the artifacts 1. Declare git URLs <?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"> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> ... <scm> <connection>scm:git:git@bitbucket.org:<some-org>/shared-lib.git</connection> <url>scm:git:git@bitbucket.org:<some-org>/shared-lib.git</url> <developerConnection>scm:git:git@bitbucket.org:<some-org>/shared-lib.git</developerConnection> </scm> .... <distributionManagement> <releaseRepository> <id>nexus-releases</id> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/releases/</url> </releaseRepository> </distributionManagement> 2. Declare release repository
  13. Releasing the artifacts .... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.4.1</version>

    </plugin> </plugins> </build> ... </project> 4. mvn release:prepare mvn release:perform (and that’s it) 3. Use the release plugin
  14. Nexus Setup •A war that can be deployed to Tomcat

    •Register an ‘ admin’ user •And you’re good to go.
  15. Nexus Setup

  16. Questions? avinashc@thoughtworks.com