Skip to content

dsf mirabaud jenkins nexus integration

jodacalc edited this page Jun 6, 2019 · 1 revision

Jenkins - Nexus integration

Nexus is used to both host dependencies for devonfw projects to download (common Maven ones, custom ones such as ojdb and even devonfw so-far-IP modules). Moreover, it will host our projects' build artifacts (.jar, .war, …​) and expose them for us to download, wget and so on. A team should have a bidirectional relation with its Nexus repository.

1. Jenkins credentials to access Nexus

By default, when Nexus is installed, it contains 3 user credentials for different purposes. The admin ones look like this: admin/admin123. There are also other 2: deployment/deployment123 and TODO.

// ADD USER TABLE IMAGE FROM NEXUS

In this case, let’s use the ones with the greater permissions: admin/admin123.

Go to Credentials > System (left sidebar of Jenkins) then to Global credentials (unrestricted) on the page table and on the left sidebar again click on Add Credentials.

This should be shown in your Jenkins:

jenkins new nexus credentials

Fill the form like this:

jenkins new nexus credentials filled

And click in OK to create them. Check if the whole thing went as expected:

jenkins new nexus credentials completed

2. Jenkins Maven Settings

Those settings are also configured (or maybe not-yet-configured) in our devonfw distributions in:

/${devonfw-dist-path}
    /software
        /maven
            /conf
                settings.xml

Go to Manage Jenkins > Managed files and select Add a new Config in the left sidebar.

jenkins new maven settings

The ID field will get automatically filled with a unique value if you don’t set it up. No problems about that. Click on Submit and let’s create some Servers Credentials:

jenkins new maven settings servers

Those Server Credentials will allow Jenkins to access to the different repositories/servers that are going to be declared afterwards.

Let’s create 4 server credentials.

  • my.nexus: Will serve as general profile for Maven.

  • mynexus.releases: When a mvn deploy process is executed, this will tell Maven where to push releases to.

  • mynexus.snapshots: The same as before, but with snapshots instead.

  • mynexus.central: Just in case we want to install an specific dependency that is not by default in the Maven Central repository (such as ojdbc), Maven will point to it instead.

jenkins new maven settings servers credentials

A more or less complete Jenkins Maven settings would look look like this:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <mirrors>
        <mirror>
            <id>mynexus.central</id>
            <mirrorOf>central</mirrorOf>
            <name>central</name>
            <url>http://${URL-TO-YOUR-NEXUS-REPOS}/central</url>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>my.nexus</id>
            <!-- 3 REPOS ARE DECLARED -->
            <repositories>
                <repository>
                    <id>mynexus.releases</id>
                    <name>mynexus Releases</name>
                    <url>http://${URL-TO-YOUR-NEXUS-REPOS}/releases</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
                <repository>
                    <id>mynexus.snapshots</id>
                    <name>mynexus Snapshots</name>
                    <url>http://${URL-TO-YOUR-NEXUS-REPOS}/snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>public</id>
                    <name>Public Repositories</name>
                    <url>http://${URL-TO-YOUR-NEXUS}/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <!-- HERE IS WHERE WE TELL MAVEN TO CHOOSE THE my.nexus PROFILE -->
    <activeProfiles>
        <activeProfile>my.nexus</activeProfile>
    </activeProfiles>
</settings>

3. Use it in Jenkins Pipelines

Clone this wiki locally