How exactly should gitlab-ci behave to version my project ?

A simple git flow on gitlab could be:

  • commit on master -> build, test and deploy to staging
  • tag on master -> build, test and deploy to production

But how do you deal with version ?

1- should the deploy version be based on the tag ? if yes do you update the pom.xml with the tag name? (seems dangerous if you make a mistake)

2- should the version be taken care of by maven release ? if yes, how do you trigger deploy to production ? (because the tag is now managed by maven)

What would be best practice here ? (you can propose other flow)


I personally dislike it if the release/deployment process makes any commits or tags on its own. Therefore, in general my preferred approach is:

  1. Versions are managed manually, but possibly using utility scripts. E.g. if a developer runs ./bump-version v1.2.3 that could take care of updating the version number in the correct places and creating a tag, and could ensure that the version number was increased correctly.

  2. The CI can include checks that all version information is consistent: If the build was triggered by a tag, does the pom.xml version match the version in the tag? A couple of regexes is all that's typically needed. You wouldn't write these checks as part of your unit tests, but as a separate test script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.