【问题标题】:Running npm version scripts in Azure Pipelines在 Azure Pipelines 中运行 npm 版本脚本
【发布时间】:2019-03-29 11:23:01
【问题描述】:

我正在尝试在 Azure DevOps Pipelines 上为具有自动递增版本号的 nodejs 项目的托管 Ubuntu 代理设置 CI。

我在使用 npm 版本补丁增加版本时遇到错误

[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
> identity@2.0.2 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:

即使我不推送到 git,错误仍然存​​在。

作为 CI 的一部分,我已经清理了 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

我已经在 CI 中使用 shell 脚本清理了构建源目录,但无济于事。

任何方向都会有所帮助。

【问题讨论】:

    标签: node.js npm azure-devops azure-pipelines azure-pipelines-build-task


    【解决方案1】:

    根据 npm-version docs,如果工作目录不干净,该命令将失败。我从你的错误日志中可以看到 package-lock.json 文件被修改,导致 npm version 命令失败。

    为了解决这个问题,要么提交 package-lock.json 文件,要么像这样使用 force 标志

    npm version patch --force
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-09
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多