Deploying artifacts to Nexus 3 using maven

141 views Asked by At

Using the Jenkins pipeline, I'm trying to deploy artifacts to the Nexus3 repository.

After reading the documentation here, I wrote a curl request:

request = "curl -k -w '%{http_code}' -F maven.generate-pom=true -F maven2.groupId=${group} \
               -F maven2.artifactId=${artifactId} -F maven.packaging=zip -F maven2.version=${projectVersion} \
               -F maven2.asset1=@${filePath} -F maven2.asset1.extension=${extension} \
               -u "+'$NEXUS_USER:$NEXUS_PASSWORD'+" \
               https://nexus.w.mcb.md/service/rest/v1/components?repository=${repoName}"

        response = sh(script: request, returnStdout: true)

I am getting an error in Jenkins:

ERROR: Artifact did not upload to Nexus! Response code is [{"id":"maven.packaging","message":"Unknown component field 'maven.packaging'"},{"id":"maven.generate-pom","message":"Unknown component field 'maven.generate-pom'"},{"id":"maven2.groupId","message":"Unknown component field 'maven2.groupId'"},{"id":"maven2.asset1.extension","message":"Unknown component field 'maven2.asset1.extension'"},{"id":"maven2.version","message":"Unknown component field 'maven2.version'"},{"id":"maven2.artifactId","message":"Unknown component field 'maven2.artifactId'"},{"id":"directory","message":"Missing required component field 'Directory'"},{"id":"filename","message":"Missing required asset field 'Filename' on '1'"}]400

Pom file:

<?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"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.13</version>
        <relativePath/>
    </parent>
    <groupId>test.one</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>test</name>
    <description>test</description>
    <modules>
        <module>test-boot</module>
        <module>test-dto</module>
    </modules>

Can someone explain to me where the error is?

0

There are 0 answers