I’m wondering if I could get some guidance on how to automate versioning in my multibranch pipeline. Recently I used a plugin called conventional commits, which I thought would work great for bumping the version in a package.json. However I keep running into a problem trying to execute one of the plugins methods “NEXT_VERSION = nextVersion(writeVersion: true)” I get the following error:
Cannot run program "npm" (in directory "/var/lib/jenkins/workspace/FireLink_PR-460/packages/web"): error=2, No such file or directory .
As I look at the documentation for this plugin it looks like they are setting NEXT_VERSION = nextVersion(writeVersion: true) in the environment block within the Jenkinsfile. Documentation here: Conventional Commits
The problem with me doing this is I have to cd to a different directory, “/packages/web” within my project to update the appropriate package.json. I’m able to to get to that directory fine, and I can see that the existing version is being read and it appears that the plugin knows what the next version should be, however the new value isn’t written to the package.json and the pipeline fails with “java.io.IOException: error=2, No such file or directory”. I’m not sure if this is due to me running this method within a stage block?
— Jenkinsfile I’m using is at the bottom of this post —
I’d like to have the version bumped based on Conventional Commits if possible. I’ve done some research and saw that I could use different tools to accomplish this, one solution using an npm package called “standard-version”, which I’m going to experiment with today. I wanted to see if anyone could give me some insight into how they may be automating versioning and see if there is a better path I should go down?
Thanks in advance for any help