Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining multiple Maven goals into one transaction (e.g. deploy and site-deploy, what if site-deploy fails?) [closed]

I configured the build server to do

clean javadoc:jar deploy site-deploy

Now if site-deploy fails (because the site did not build, or somebody used the wrong parent pom), the build server shows a failed build, but the deploy was already applied.

Is there a way to "combine" deploy and site-deploy in a transactional way?

Or should I use a different chain of goals/phases (e.g. install before site-deploy)?

like image 808
J Fabian Meier Avatar asked Jul 07 '17 07:07

J Fabian Meier


People also ask

Which of the following Maven command makes sure that all lifecycle methods are called?

Usual Command Line Calls If you want to run the unit tests, run test . This command executes each default lifecycle phase in order ( validate , compile , package , etc.), before executing verify .

Which of the following are correct Maven goals?

A Maven plugin is a group of goals; however, these goals aren't necessarily all bound to the same phase. As we can see, the Failsafe plugin has two main goals configured here: integration-test: run integration tests. verify: verify all integration tests passed.

What are the three builds in the Maven life cycle?

As an example, a typical Maven Build Lifecycle consists of the following sequence of phases. Resource copying can be customized in this phase. Validates if the project is correct and if all necessary information is available. Source code compilation is done in this phase.

What should I write in goals when building Maven project?

From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. In the list that opens, select Run Maven Goal. In the Select Maven Goal dialog, specify a project and a goal that you want to execute before launching the project. Click OK.


1 Answers

Here I am proposing a close solution with the help bash && operator

mvn clean javadoc:jar install site-deploy && mvn deploy:deploy-file {PARAM}

This will let you

  • fails the build if any of the goal fails during install phase
  • if site-deploy fails, then your artifact will not be pushed/deployed to your remote repository
  • no need to write any custom rollback mechanism if site-deploy fails

The only case this will fail is when your deploy goal fails, there will be no rollback site-deploy. I think failure of deploy phase will be very much rare.

like image 175
Rishikesh Darandale Avatar answered Sep 20 '22 09:09

Rishikesh Darandale