Jenkins升级后部署demo.war到Nexus失败,返回500错误求助
Failed to deploy artifacts: Could not transfer artifact :demo:war:1.0.1 from/to releases (http://demo_server_url:8081/nexus/content/repositories/releases): Failed to transfer file: http://demo_server_url:8081/nexus/content/repositories/releases/demo-server/1.0.1/demo-1.0.1.war. Return code is: 500, ReasonPhrase:Server Error.
[Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline
ERROR: Uploading file demo.war failed. Finished: FAILURE
Hey there, let's dig into this 500 Server Error you're facing after upgrading Jenkins. A 500 status means Nexus hit an unexpected internal issue, so let's work through the most likely fixes step by step:
1. Check Nexus Server Logs First
This is the most critical step—Nexus logs will tell you exactly what went wrong on the server side. Look for the log file at sonatype-work/nexus3/log/nexus.log (default path; adjust if you customized it). Search for entries around the time your Jenkins job failed. Common issues you might see:
- Disk space exhaustion (Nexus can't write the war file)
- Permissions errors on the repository storage directory
- Corrupted repository metadata
- Issues with the repository configuration (e.g., missing storage path)
2. Verify Jenkins Deployment Configuration
Jenkins plugin upgrades sometimes reset or break existing configs:
- Double-check your Maven/Gradle
settings.xml(either in Jenkins global config or the job's local config) for correct Nexus credentials and repository URL. Make sure the username/password has deploy permissions on thereleasesrepository in Nexus. - Confirm you're deploying to the right repository type: your
1.0.1version is a release, so ensure you're targeting thereleasesrepo (notsnapshots), and that the repo allows deployments.
3. Validate the Artifact and Permissions
- Check if your
demo.waris corrupted: run a checksum (MD5/SHA) on the local file in Jenkins workspace and compare it to the original build artifact. A corrupted file can cause Nexus to throw 500 when trying to process it. - Ensure the Jenkins user (the one running the pipeline) has network access to Nexus: test connectivity from the Jenkins server with
curl http://demo_server_url:8081/nexus/content/repositories/releases—you should get a valid HTML response (or 401 if auth is required, which is expected). - Check Nexus storage directory permissions: the user running Nexus needs write access to the directory where the
releasesrepo stores artifacts. Runls -ld /path/to/nexus/repos/releasesto verify.
4. Test Deployment Outside Jenkins
Rule out Jenkins-specific issues by deploying directly from your local machine or the Jenkins server using the Maven/Gradle command:
mvn deploy -DskipTests -DaltDeploymentRepository=releases::default::http://demo_server_url:8081/nexus/content/repositories/releases -Dusername=your-nexus-user -Dpassword=your-nexus-pass
If this command succeeds, the problem is definitely in Jenkins (plugin compatibility or config). If it fails with the same 500, focus on Nexus server issues.
5. Check Plugin Compatibility
Jenkins upgrades can introduce plugin conflicts:
- Roll back the Jenkins plugins related to deployment (e.g., Maven Integration Plugin, Nexus Artifact Uploader) to the versions that worked before the upgrade. You can do this via Jenkins > Manage Plugins > Installed > Find the plugin > Roll back.
- Alternatively, update those plugins to the latest stable versions that are compatible with your new Jenkins version. Check the plugin documentation for compatibility notes.
6. Verify Nexus Repository Configuration
Log into Nexus UI and check your releases repository settings:
- Ensure Allow Redeploy is enabled if you're re-deploying the same
1.0.1version (though usually this throws a 409 Conflict, but misconfigs can sometimes lead to 500). - Confirm the repository's storage path exists and is accessible. If you recently moved Nexus storage, this could be the issue.
Start with the Nexus logs—they'll give you the most precise clue. Once you have that info, you can zero in on the exact fix.
内容的提问来源于stack exchange,提问作者nk07

