333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Node.js
# Build a general Node.js application with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/javascript
# demo: https://github.com/parcel-bundler/parcel/blob/master/azure-pipelines-template.yml
 
jobs:
- job: {% raw %}${{ parameters.name }}{% endraw %}
  pool:
    vmImage: {% raw %}${{ parameters.vmImage }}{% endraw %}
  strategy:
    matrix:
      {%- for version in versions %}
      node_{{version | replace('.', '_')}}:
        node_version: {{version}}
      {%- endfor %}
    maxParallel: {{versions.length}}
  steps:
  - task: NodeTool@0
    inputs:
      versionSpec: $(node_version)
    displayName: 'Install Node.js'
{% raw %}
  # Set ENV
  - ${{ if ne(parameters.name, 'windows') }}:
    - script: |
        echo $PWD
        export PATH="$PATH:$PWD/node_modules/.bin"
        echo "##vso[task.setvariable variable=PATH]$PATH"
      displayName: Set ENV
  - ${{ if eq(parameters.name, 'windows') }}:
    - script: |
        echo %cd%
        set PATH=%PATH%;%cd%\node_modules\.bin
        echo "##vso[task.setvariable variable=PATH]%PATH%"
      displayName: Set ENV
{% endraw %}
  - script: |
      {%- if npminstall %}
      npm i npminstall && npminstall
      {%- else %}
      npm i
      {%- endif %}
    displayName: 'Install Packages'
  - script: |
      npm run {{command['azure-pipelines']}}
    displayName: 'Build & Unit Test'
  - {% raw %}${{ if ne(parameters.name, 'windows') }}:{% endraw %}
    - script: |
        {%- if npminstall %}
        npminstall codecov && codecov
        {%- else %}
        npm i codecov && codecov
        {%- endif %}
      displayName: 'Report Coverage'