I want to automatically increment a version number in my package.json as I merge in a pull request (to master). This will trigger a build and deploy using the correct version number.
Having to manually set the version number is irritating as multiple branches could expect to have the same version number, but only the first one merged in can use it, then the other pull request would need to be rejected due to the version number being incorrect.
My plan is to have a custom field on the jira issue associated with the pull request that specifies major/minor/patch, then use ApplicationLinkService in a bitbucket plugin (RepositoryMergeCheck seems the most appropriate) to grab that value.
I then want to modify the commit before it gets merged into master. It should grab the package.json from the head of master and use that and the jira field to determine the new value. Once it merges into master, bamboo automatically builds and attempts to publish so I need the version number to be correct before then.
I know of CommandBuilder to run git commands, but I can't see how it would help.
Is it possible to do this? The two issues I have with my current method are:
- I couldn't find a way to modify the commit itself before it's merged in from the plugin.
- I can't find a way to grab files from the branches (feature or master) from the plugin.