1
votes

I have an npm source code that needs to be built and push to npmjs repository. In details it looks like:

Build pipeline:

1) Get sources from Bitbucket repository
2) Get from package.json version number (ex. 0.0.3), increase it by 0.0.1 (0.0.4) and add this value to build variables $(version)
3) Make NPM install and build.
4) Take package-0.0.4.tgz and package.json to the artifacts folder and publish it.

Release pipeline:

1) Download artifacts
2) Extract package-0.0.4.tgz to npm-publish folder
3) Copy package.json to npm-publish folder
4) Publish npm folder to npmjs repository.

My question - is it possible to commit to Bitbucket repository updated package.json file with new version after publishing to npmjs repository?

1
Hi @Vasiliy Vegas Did you check out below scripts? How was it going?Levi Lu-MSFT
Hi, @LeviLu-MSFT! Thanks for your answer! Unfortunately, I've switched to another project, so I will check your answer in a few days. Sorry about that and thanks again for your answer!Vasiliy Vegas
Hi, @LeviLu-MSFT! Sorry for delay, just want to say, that your answer is correct! Thanks!Vasiliy Vegas

1 Answers

1
votes

It is possible to commit to Bitbucket repository. You only need to add a script task to execute the git commands.

For below example. I add a powershell task to run below commands in the pipeline to commit changes and push to the Bitbucket repo.

- powershell: |

   git config --global user.email "[email protected]"
   git config --global user.name "user.name"

   #echo "some-text"  > filename.txt

   git add .

   git commit -m "update package version"

   git push https://username:[email protected]/name/repo.git HEAD:master -q
   #if your password or username contain @ replace it with %40

  displayName: 'push to bitbucket'