'Jenkins cannot deploy to nexus
when deploy from jenkins to nexus with the Nexus Artifact Uploader plugin i get the following error:
java.lang.NullPointerException
at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep.getUsername(NexusArtifactUploaderStep.java:132)
at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep$Execution.run(NexusArtifactUploaderStep.java:239)
at sp.sd.nexusartifactuploader.steps.NexusArtifactUploaderStep$Execution.run(NexusArtifactUploaderStep.java:217)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate2(ACL.java:449)
at hudson.security.ACL.impersonate(ACL.java:461)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
But there is everything correct in the jenkinsfile (the credentialsid, etc.)
Jenkinsfile:
agent any
tools {
jdk 'jdk-14'
}
environment {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "https"
NEXUS_URL = "repo.vironlab.eu"
NEXUS_REPOSITORY = "maven-snapshot"
NEXUS_CREDENTIAL_ID = "nexus"
PROJECT_VERSION = "2.0.0-SNAPSHOT"
}
stages {
stage("Clean") {
steps {
sh "chmod +x ./gradlew";
sh "./gradlew clean";
}
}
stage("Build") {
steps {
sh "./gradlew build";
}
post {
success {
archiveArtifacts artifacts: 'vextension-common/build/libs/vextension-common.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-server/build/libs/vextension-minecraft-server.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-proxy/build/libs/vextension-minecraft-proxy.jar', fingerprint: true
}
}
}
stage("Build ShadowJar") {
steps {
sh "./gradlew shadowJar";
}
post {
success {
archiveArtifacts artifacts: 'vextension-common/build/libs/vextension-common-full.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-server/build/libs/vextension-minecraft-server-full.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-proxy/build/libs/vextension-minecraft-proxy-full.jar', fingerprint: true
}
}
}
/*stage("Docs") {
steps {
sh "./gradlew dokkaHtmlMultiModule";
sh "rm -r /var/www/docs/vextension-v2.0.0"
sh "mkdir /var/www/docs/vextension-v2.0.0"
sh "cp -r build/vextension-v2.0.0 /var/www/docs/"
}
}*/
stage("Sources") {
steps {
sh "./gradlew kotlinSourcesJar";
}
post {
success {
archiveArtifacts artifacts: 'vextension-common/build/libs/vextension-common-sources.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-server/build/libs/vextension-minecraft-server-sources.jar', fingerprint: true
archiveArtifacts artifacts: 'vextension-minecraft-proxy/build/libs/vextension-minecraft-proxy.jar', fingerprint: true
}
}
}
stage("Publish") {
steps {
script {
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: "eu.vironlab.vextension",
version: PROJECT_VERSION,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts:
[
[
artifactId: "vextension-common",
classifier: '',
file : "vextension-common/build/libs/vextension-common.jar",
type : "jar"
],
[
artifactId: "vextension-common",
classifier: 'sources',
file : "vextension-common/build/libs/vextension-common-sources.jar",
type : "jar"
],
[
artifactId: "vextension-common",
classifier: '',
file : "vextension-common/build/pom/pom.xml",
type : "pom"
],
[
artifactId: "vextension-minecraft-server",
classifier: '',
file : "vextension-minecraft-server/build/libs/vextension-minecraft-server.jar",
type : "jar"
],
[
artifactId: "vextension-minecraft-server",
classifier: 'sources',
file : "vextension-minecraft-server/build/libs/vextension-minecraft-server-sources.jar",
type : "jar"
],
[
artifactId: "vextension-minecraft-server",
classifier: '',
file : "vextension-minecraft-server/build/pom/pom.xml",
type : "pom"
],
[
artifactId: "vextension-minecraft-proxy",
classifier: '',
file : "vextension-minecraft-proxy/build/libs/vextension-minecraft-proxy.jar",
type : "jar"
],
[
artifactId: "vextension-minecraft-proxy",
classifier: 'sources',
file : "vextension-minecraft-proxy/build/libs/vextension-minecraft-proxy-sources.jar",
type : "jar"
],
[
artifactId: "vextension-minecraft-proxy",
classifier: '',
file : "vextension-minecraft-proxy/build/pom/pom.xml",
type : "pom"
]
]
);
}
}
}
}
}
Is there anyone who has an idea how i can fix that error? I cannot find any mistake in the Jenkinsfile or in my jenkins configuration.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|