2

I'm trying to build the CI/CD Pipeline for my project in VSTS. The tests, build and deployment flow is all fine and working as expected.

But I couldn't manage to commit the auto increased version number in the package.json to the github repo.

My steps on the VSTS agent are as per this image. enter image description here

I wrote the following npm scripts in Increase Version Number step to increase the minor version number.

git config user.email "ttcgabc123@gmail.com"
git config user.name "ttcg"

npm version minor

git commit
git push origin master --tags

It does increase the version number from 0.2.0 to 0.3.0 but, it doesn't push the changes made back to my github repo and I couldn't manage to commit/push these changes.

Please see the output of the above step in VSTS build. On line no. 12, you can see the new version number.

enter image description here

I tried to use git remote add origin https://github.com/ttcg/react-workout-diary.git, but it shows the error message fatal: remote origin already exists.

Could you please advise me how can I automate to increase the version number in my CI/CD pipeline?

TTCG
  • 8,805
  • 31
  • 93
  • 141
  • 1
    git push origin master --tags would only push the tags, what happens if you change it to 'git push origin master' ? Also, if you have this setup as a continuous integration build, you may end up in a never ending loop of builds since every time a build runs, you're updating the branch that triggers the build. If you're just trying to have a unique package id, then you might want to try to use a build variable (build number or build id) in the 3rd position of your version. – DenverDev Apr 02 '19 at 13:49
  • There is no difference without --tags. It looks like I need to run that command manually on the dev machine to increase the version before commiting/pushing to the repo to prevent the loop or use the build number as you suggested. Could you please provide the good resource for that build number? – TTCG Apr 02 '19 at 15:52
  • You could likely use BuildID or Rev:.r depending on how you're doing your builds/branching/versioning. These are pipeline variables, so you may need to pass them as command line arguments to your package process or use an additional task or custom script. https://learn.microsoft.com/en-us/azure/devops/pipelines/build/options?view=azure-devops&tabs=yaml – DenverDev Apr 02 '19 at 17:31

0 Answers0