0

I need to execute sequence of two different maven goals that both accept argument with a same name, but I need to pass different value for this argument to each of these goals. To be more specific, I need to execute release:prepare followed by scm:checkin and both of these goals accept argument pushChanges which I need to set to false for the first goal and to true for the second goal (this is simplified scenario since between these two maven goals there is a third goal executed but that is not relevant). In addition due to design of our CI pipeline this all needs to be done using maven command line (parameters cannot be set in pom.xml for individual plugins).

Any idea on how this can be achieved in an elegant way ?

  • Why do you like to use scm:checkin instead of the part in maven-release-plugin which works...what is the problem you are trying to solve? What does the third goal will do ? And what is the purpose cause it sounds a little bit weird... – khmarbaise Sep 06 '17 at 06:44
  • I'm attempting to solve problem related to release:prepare failing when there are changes pushed to remote git branch when goal is executed (since it does not pull changes from remote branch before pushing transformed pom's from local branch). So my idea of a solution is to disable pushing changes from local git branch to remote git branch for release plugin, and do scm:scheckin scm:scheckout after release prepare is done. Since this is really issue for us, due to our release:prepare lasting few hours and it fails at very end in case anything gets pushed to origin in the time of its execution – Ivan Chalupka Sep 06 '17 at 10:44
  • If I understood your issue correctly, I think you can do something like: mvn -DpushChanges=false release:prepare – carlosvin Sep 06 '17 at 15:30
  • This would mean in the end that you are tagging a state of code which you do not really have released. Apart from that if something is working on branch where a release is being built there is something going wrong. Each dev should work on it's own branch and never push/commit changes to a release branch (might that master or a separate release branch). Changes should only being integrated into such branch via explict merges... – khmarbaise Sep 07 '17 at 06:13
  • At the end I did solve this problem as proposed by @carlosvin by setting -DpushChanges=false for release plugin and pushing changes to remote branch in post-build script `git pull --no-ff origin master` `git push origin master` `git push --tags origin master`. And it works, although it messes up with your history a little bit (since it shows any commit to remote branch that is made at the time of release:prepare both before release tag and after release tag, which may create illusion that such commit is part of release even though its not). But it seems like better solution than rebase – Ivan Chalupka Sep 07 '17 at 13:32

0 Answers0