How to use nexus with http protocol when building with maven?
Description of the scene
Currently, the platform supports Nexus with HTTPS protocol by default. When using a dependency repository with HTTP protocol in Nexus, the Jenkins pipeline created using the Maven or Maven Build and Distribute template will fail to execute because the platform provides Maven 3.8.1, which prohibits the use of HTTP protocol for security reasons after Maven 3.8.1. If you need to use Nexus with HTTP protocol, follow the steps below to resolve the issue.
Prerequisites
The Jenkins you are using must be the Jenkins tool created with the
The solution
-
In the left navigation bar, click DevOps Toolchain > Integrations.
-
Click the Jenkins tool card.
-
Click the Instance Name on the right side of Instance to enter the deployment details page.
-
In the Build Node area below, find the platform’s default build node Java.
-
Click Update Build node, turn on the Maven Settings file switch, and paste the following code into the Content code box:
<?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>maven-default-http-blocker</id> <mirrorOf>!*</mirrorOf> <name>Pseudo repository to mirror external repositories initially using HTTP.</name> <url>http://0.0.0.0/</url> <blocked>true</blocked> </mirror> </mirrors> </settings> -
Click on Update. After the update is completed, please trigger the pipeline again to use the HTTP protocol to pull the dependency packages.