Sharath Chandra
Sharath Chandra

Reputation: 704

Running npm version scripts in Azure Pipelines

I am trying to setup CI on Azure DevOps Pipelines, on Hosted Ubuntu agent for a nodejs project with auto incrementing version numbers.

I am getting the errors on the incrementing the version using npm version patch

[command]/opt/hostedtoolcache/node/8.12.0/x64/bin/npm run release-it
npm ERR! Git working directory not clean.

npm ERR! M package-lock.json
> [email protected] release-it /home/vsts/work/1/s

> npm version patch && git push --follow-tags
npm ERR! A complete log of this run can be found in:

The error persists even if I don't push to git.

As a part of the CI, I have cleaned the repo

resources:
- repo: self
  clean: true

trigger:
  batch: true
  branches:
    include:
    - '*'

pr:
  autoCancel: true
  branches:
    include:
    - 'master'

jobs:
- job: identity_release
  timeoutInMinutes: 20
  workspace:
    clean: all
  pool:
    vmImage: 'ubuntu-16.04'
    demands: 
    - npm
  condition: or(eq(variables['Build.Reason'], 'Manual'), eq(variables['Build.Reason'], 'Schedule'))
  steps:
    - script: echo The build reason is $(Build.Reason) and branch is $(Build.SourceBranch)
    - template: release-build-steps.yml

I have cleaned the build sources directory using shell script in CI with no avail.

Any direction will be helpful.

Upvotes: 1

Views: 3371

Answers (1)

Manos Pasgiannis
Manos Pasgiannis

Reputation: 1783

As per npm-version docs the command will fail if the working directory is not clean. I can see from your error log that the package-lock.json file is modified, causing the npm version command to fail.

In order to fix this, either commit the package-lock.json file or use the force flag like this

npm version patch --force

Upvotes: 1

Related Questions