Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strategy for maven deploy via a Jenkins job

I have a Jenkins job that use maven build goals 'clean package deploy' for the master git branch. However, due to the nexus repo not allowing redeploys, if the Jenkins job runs a second time without the version changing, it will fail with the expected 400 Bad Request error:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
    org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) 
    on project common-library: 
Failed to deploy artifacts: Could not transfer artifact 
    net.bacon.common:common-library:pom:1.2.13 from/to bacon-releases 
    (https://maven.bacon.com/nexus/content/repositories/releases): 
Failed to transfer file: 
    https://maven.bacon.com/nexus/content/repositories/releases/net/bacon/common/common-library/1.2.13/common-library-1.2.13.pom. 
Return code is: 400, ReasonPhrase:Bad Request.

Can anyone suggest a different strategy, whereby the deploy goal can run without making the Jenkins job fail?

like image 463
Streetdaddy Avatar asked Apr 22 '13 13:04

Streetdaddy


2 Answers

what we do is automatic snapshot builds. then, the version is automatically incremented.

for release build, we use the maven release plugin and enter the version manually. you can, however, let the release plugin do the work. it will remove the "-SNAPSHOT" build, deploy, and then, for the next release version increment the last digit and append the "-SNAPSHOT" again.

for the distribution management, you can have two repos, one for snapshots and one for releases, with different redeploy settings.

like image 166
rmalchow Avatar answered Sep 27 '22 20:09

rmalchow


We apply a "double action" solution:

  • Increment version
  • Run mvn install
  • Run tests
  • If all passed, we run mvn deploy

This way, we do not try to deploy before we know all passed and we have a unique version deployed every time.

I hope this helps.

like image 20
Eldad Assis Avatar answered Sep 27 '22 22:09

Eldad Assis