Issue
I am currently using Jenkins version 2.222.4, Nexus repository 3.X and NexusArtifactUploader jenkins plugin. This all is on organisation's production.
I have a maven project which I am able to build using jenkins pipeline. However, for uploading artifact I am having issue with NexusUploadArtifact plugin.
At the NexusUpload stage the pipeline is failing with below error.
Error: Uploading file filename.jar failed
I do not see any other error message which could have helped me to debug the issue.
I tried with two ways with NexusArtifactUploader plugin but ended with same error.
First way:
stage('Upload Nexus Artifact') { steps { script { def pom = readMavenPom file: 'pom.xml' nexusArtifactUploader artifacts: [[artifactId: "${pom.artifactId}", classifier: '', file: "target/${pom.artifactId}-${pom.version}.${pom.packaging}", type: "${pom.packaging}"]], credentialsId: 'Here_Is_The_Creds', groupId: "${pom.groupId}", nexusUrl: 'nexus.something.com', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-snapshots', version: "${pom.version}" } }
}
Second way
stage('Upload Nexus Artifact') { steps { script { def pom = readMavenPom file: 'pom.xml'
nexusArtifactUploader( nexusVersion: 'nexus3', protocol: 'http', nexusUrl: 'nexus.something.com', groupId: "${pom.groupId}", **version: "${pom.version}",** repository: 'maven-snapshots', credentialsId: 'Here_Is_The_Creds', artifacts: [ [artifactId: "${pom.artifactId}", file: "target/${pom.artifactId}-${pom.version}.${pom.packaging}", type: "${pom.packaging}"] ] ) } }
When I read documentation of NexusUploadArtifact jenkins plugin, I learned that this plugin is not for artifacts generated by Maven project. Added snap and url for reference.
Many of the blogs outside stackoverflow and answers on stackoverflow suggested to use Sonatype Nexus Platform Plugin for Jenkins but in my case as I am on Jenkins 2.222.4, this plugin is not supported.
I tried to replicate this on my local machine but with latest version of Jenkins along with NexusArtifactUploader plugin and it did worked.
So, I am stuck on how can this be resolved. Can anyone help me on this as Jenkins version upgrade and Sonatype Nexus Platform Plugin are not the correct fit for me at this moment.
Thanks!
Solution
Update.
As mentioned and suggested by @khmarbaise, I was able to deploy artifacts to nexus with Maven without any plugin. Also, when I tried with maven, first I got complete error in Jenkins console about authentication then post correcting credentials I was able to upload artifact using Maven and using NexusArtifactUpload jenkins plugin. One issue / bug I found in NexusArtifactUpload jenkins plugin that, it intermittently do not show status of artifact upload on jenkins's console output log and that is the reason I decided to go with Maven.
Answered By - Swapnil Shrishrimal
Answer Checked By - David Marino (JavaFixing Volunteer)