0

I am trying to adding package.json version change script in azure-pipeline.yaml file. A script would change version in package.json and then build/deploy an artifact with new version for more clarity here I am sharing Image.

Image

For example, current version is 1.0.0. We select “Patch” and run a pipeline. A script changes version to 1.0.1, build a package and deploy as artifact@1.0.1. Then it creates a PR where package.json version 1.0.0 -> 1.0.1

Azure-pipeline.yaml

trigger:
  - master
pr:
  branches:
    exclude:
      - "*"
parameters:
  - name: releaseType
    displayName: Release Type
    type: string
    default: patch
    values:
      - major
      - minor
      - patch
resources:
  repositories:
    - repository: templates
      type: github
      name: BBB-Prod/template_repo
      endpoint: ###
      ref: refs/tags/v0.8-alpha
stages:
  - template: pipeline_templates/build.yml@templates
    parameters:
      agentPoolName: Prod
      agentOS: Linux
      jobTimeoutInMinutes: 180
      buildType: npm
      buildCache: true
      nodeJsVersion: 14.x
      npmWorkingFolder: ""
      npmInstallArgs: --no-package-lock
      npmCollectBuildInfo: true
      npmInstallThreads: "3"
      packageFeedSnapshotProjectKey: BBB-npm-PrivateDependencies
      npmBuildArgs: run build-lib
      npmTest: false
      npmTestArgs: test
      npmPublish: true
      npmPublishArgs: ""
      packageFeedResolveServiceConnection: JFrog_Artifactory
      packageFeedReleaseResolveRepo: bbbC-NPM-Engineering-Virtual
      packageFeedPublishServiceConnection: JFrog_Artifactory
      packageFeedSnapshotPublishRepo: bbb-npm-PrivateDependencies
      publishTestResults: true
      publishTestResultsFormat: NUnit3
      publishTestResultsFiles: "**/TEST-*.xml"
      publishCoverageResults: true
      publishCoverageTool: Jacoco
      publishCoverageReportDirectory: $(System.DefaultWorkingDirectory)/target/jacoco
      publishCoverageResultsSummaryFileLocation: $(System.DefaultWorkingDirectory)/target/jacoco/jacoco.xml
      insertPreBuildSteps:
        - script: |
            if [ "$(releaseType)" == "patch" ]; then
              npm version patch --no-git-tag-version
            elif [ "$(releaseType)" == "minor" ]; then
              npm version minor --no-git-tag-version
            elif [ "$(releaseType)" == "major" ]; then
              npm version major --no-git-tag-version
            fi
            dir
          displayName: custom pre-build steps

Error which I am getting

error

0 Answers0