Child pages
  • Jenkins Development Environment with Nexus
Skip to end of metadata
Go to start of metadata

How to Set up the Nexus Repository Manager to Build Jenkins

  1. download the latest Nexus war from here.
  2. drop the war in your tomcat instance or some other container.
  3. bring up the Nexus Manager and make sure you configure all of the proxy repositories that Jenkins requires (list below).
  4. replace your ~/.m2/settings.xml file with the version below, editing the Nexus instance address as needed.

This page likely needs to be updated

There was a shift to using Artifactory instead of nexus, a few additional repos are needed to be proxied: http://maven.tmatesoft.com/content/repositories/releases/ and http://bits.netbeans.org/maven2/ when using nexus.


Note

The line <mirrorOf>external:*</mirrorOf> in settings.xml allows nexus to pass-through file:// based url's declared as <repository> elements in several of the plugin poms (and no, it is not best practice to use the source tree as a maven repository!)

Okay, now you can build. It will be the usual slow going if you remove your local maven build repository (default location $HOME/.m2/repository), which is advisable at first, to force nexus to cache all of the Jenkins artifacts.

After your Nexus instance is populated, builds from scratch are very fast.

MAVEN SETTINGS.XML ($HOME/.m2/settings.xml):

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>external:*</mirrorOf>
      <!-- your address may differ: -->
      <url>http://localhost:8080/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>


PROXY REPOSITORY CONFIGURATION:

You only need to add http://maven.jenkins-ci.org/content/repositories/releases/ as a proxy repository with release policy at this stage. The repositories below are proxied from jenkins-ci already so you don't have to.

      <id>google</id>
      <name>Google Code</name>
        <url>http://google-maven-repository.googlecode.com/svn/repository/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>atlassian</id>
      <name>atlassian</name>
        <url>https://maven.atlassian.com/content/groups/public/</url>
            <id>https://m2proxy.atlassian.com/repository/public</id>
            <url>https://m2proxy.atlassian.com/repository/public</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>JA-SIG</id>
      <name>JA-SIG</name>
        <url>http://developer.jasig.org/repo/content/groups/m2-legacy/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>m.g.o-public</id>
      <name>m.g.o-public</name>
        <url>http://maven.glassfish.org/content/groups/public/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>laughing-panda</id>
      <name>laughing-panda</name>
        <url>http://www.laughingpanda.org/maven2/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>jclouds</id>
      <name>jclouds</name>
        <url>http://jclouds.googlecode.com/svn/repo/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>jclouds-snapshots</id>
      <name>jclouds-snapshots</name>
        <url>http://jclouds.rimuhosting.com/maven2/snapshots/</url>
        <repositoryPolicy>SNAPSHOT</repositoryPolicy>

      <id>tek42</id>
      <name>tek42</name>
        <url>http://tek42.com/maven2/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>

      <id>googlecode.java-xmlbuilder</id>
      <name>googlecode.java-xmlbuilder</name>
        <url>http://java-xmlbuilder.googlecode.com/svn/repo/</url>
        <repositoryPolicy>RELEASE</repositoryPolicy>
  • No labels

4 Comments

  1. Excellent wiki for easy follow, and for atlassian, how can I configure below information

        <id>https://m2proxy.atlassian.com/repository/public</id>
        <url>https://m2proxy.atlassian.com/repository/public</url>

  2. I followed the instruction here to use Nexus as a mirror  I add http://maven.jenkins-ci.org/content/repositories/releases/ as a proxy in my Nexus. I can create the sample project successfully, but when I execute

    > mvn package

    I got following error:

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2:29.845s
    [INFO] Finished at: Thu May 23 12:07:24 EDT 2013
    [INFO] Final Memory: 14M/122M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project jenkinstest3: Could not resolve dependencies for project rong.jenkinsplugin:jenkinstest
    3:hpi:1.0-SNAPSHOT: The following artifacts could not be resolved: org.jenkins-ci.main:jenkins-war:war:1.480.3, org.jenkins-ci.ma
    in:jenkins-war:jar:war-for-test:1.480.3, org.netbeans.modules:org-netbeans-insane:jar:RELEASE72: Could not find artifact org.jenk
    ins-ci.main:jenkins-war:war:1.480.3 in nexus (http://dsysadm-cm05:8081/nexus/content/groups/public) -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

    But I have no problem if I don't use Nexus.

    1. I had to add the following to my pom and it works fine. 

      <dependencies>

          <dependency>
                  <groupId>org.tmatesoft.sqljet</groupId>
                  <artifactId>sqljet</artifactId>
                  <version>1.1.6</version>
              </dependency>
              <dependency>
                  <groupId>de.regnis.q.sequence</groupId>
                  <artifactId>sequence-library</artifactId>
                  <version>1.0.2</version>
              </dependency>

      </dependencies>

      The maven repository at http://maven.jenkins-ci.org/content/repositories/releases/  doesn't include those 2 artifacts for some reason.

  3. I'm stuck at this point:


    [user@ring51:~/src/jenkins]-[14:18:55]
    '->$ mvn clean install;mvn -v;java -version
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO]
    [INFO] Jenkins cli
    [INFO] Jenkins core
    [INFO] Jenkins war
    [INFO] Tests for Jenkins core
    [INFO] Jenkins main module
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Jenkins cli 2.128-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ cli ---
    [INFO]
    [INFO] --- maven-enforcer-plugin:3.0.0-M1:display-info (display-info) @ cli ---
    [INFO] Maven Version: 3.3.9
    [INFO] JDK Version: 1.8.0_171 normalized as: 1.8.0-171
    [INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 4.9.0-6-amd64
    [INFO]
    [INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (display-info) @ cli ---
    [WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
    3.5.0+ required to use Incrementals.
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] Jenkins cli ........................................ FAILURE [  0.368 s]
    [INFO] Jenkins core ....................................... SKIPPED
    [INFO] Jenkins war ........................................ SKIPPED
    [INFO] Tests for Jenkins core ............................. SKIPPED
    [INFO] Jenkins main module ................................ SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.275 s
    [INFO] Finished at: 2018-06-17T14:19:20+02:00
    [INFO] Final Memory: 32M/322M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (display-info) on project cli: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    Apache Maven 3.3.9
    Maven home: /usr/share/maven
    Java version: 1.8.0_171, vendor: Oracle Corporation
    Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "4.9.0-6-amd64", arch: "amd64", family: "unix"
    openjdk version "1.8.0_171"
    OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-1~deb9u1-b11)
    OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

    then I was such an ignorant and issued:

     

    [user@ring51:~/src/jenkins]-[14:42:59]
    '->$ mvn install -Denforcer.skip=true
    [INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (enforce-banned-dependencies) @ cli ---
    [INFO] Skipping Rule Enforcement.

    The command is still running and I hope to be able to successfully invoke sonar:sonar now. Not much more I care about in this particular case case as long as it's not affecting its results. (tongue)

    Point for installing stuff directly from vendor and not necessarily always from OS package repositories.