Vasyl Stepulo
Vasyl Stepulo

Reputation: 1603

Azure DevOps - commit to Bitbucket repository updated file on release pipeline?

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?

Upvotes: 2

Views: 731

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30323

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'

Upvotes: 1

Related Questions