I have created a declarative pipeline which
- Builds the artifact using maven
- Uploads the artifact to Nexus repository
Plugins Used- Nexus Artifact Uploader Plugin
Nexus- Sonatype Nexus OSS 3.17
But here, when the upload artifact to nexus repo fails, pipeline does not fail, it shows as success. I checked that many other people have reported this issue.
So can I add any workaround here, to fail my pipeline if upload fails?
I have attached the publish artifact stage and the screenshot
stage("Publish to Nexus") {
environment {
tag_version= sh (returnStdout: true, script: 'mvn -f core build-helper:parse-version help:evaluate -Dexpression=project.version -q -DforceStdout').trim()
}
steps {
sh 'echo "tag_version=$tag_version"'
script {
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: "com.cable",
version: tag_version,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
// Artifact generated such as .jar, .ear and .war files.
[artifactId: 'core',
classifier: '',
file: "./core/target/core-$tag_version-jar-with-dependencies.jar",
type: 'jar'],
]
);
}
}
}
Console Output
Failed to deploy artifacts: Could not transfer artifact com.cable:core:jar:8.6.1 from/to snapshots (https://nexus.yo-digital.com/repository/snapshots): Failed to transfer file: https://nexus.yo-digital.com/repository/snapshots/com/cable/core/8.6.1/core-8.6.1.jar. Return code is: 400, ReasonPhrase:Repository version policy: SNAPSHOT does not allow version: 8.6.1.
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // ws
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS