Коммит
c6b149d297
|
@ -1,70 +1,89 @@
|
|||
trigger:
|
||||
- master
|
||||
- master
|
||||
|
||||
jobs:
|
||||
- job: Test
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
strategy:
|
||||
matrix:
|
||||
Node8:
|
||||
node.version: 8.x
|
||||
Node10:
|
||||
node.version: 10.x
|
||||
Node12:
|
||||
node.version: 12.x
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
displayName: 'Install Node'
|
||||
inputs:
|
||||
versionSpec: $(node.version)
|
||||
- script: npm install
|
||||
- task: Npm@1
|
||||
displayName: 'npm test'
|
||||
inputs:
|
||||
command: custom
|
||||
verbose: false
|
||||
customCommand: test
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFiles: '**/test-results.xml'
|
||||
testRunTitle: 'Test results for JavaScript'
|
||||
- task: PublishCodeCoverageResults@1
|
||||
inputs:
|
||||
codeCoverageTool: Cobertura
|
||||
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
|
||||
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'
|
||||
- job: Build
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- task: Npm@1
|
||||
displayName: 'npm pack'
|
||||
inputs:
|
||||
command: custom
|
||||
verbose: false
|
||||
customCommand: pack
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy Files to: drop'
|
||||
inputs:
|
||||
Contents: '*.tgz'
|
||||
TargetFolder: drop
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: $(Build.SourcesDirectory)/drop
|
||||
- job: Check_PackageJson_Version_Number
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- task: Npm@1
|
||||
displayName: 'npm install'
|
||||
inputs:
|
||||
command: custom
|
||||
verbose: false
|
||||
customCommand: install
|
||||
- task: Npm@1
|
||||
displayName: 'npm run check:packagejsonversion -- --azure-devops'
|
||||
inputs:
|
||||
command: custom
|
||||
verbose: false
|
||||
customCommand: run check:packagejsonversion -- --azure-devops
|
||||
parameters:
|
||||
- name: NpmTag
|
||||
type: string
|
||||
default: latest
|
||||
|
||||
stages:
|
||||
- stage: BuildStage
|
||||
jobs:
|
||||
- job: Test
|
||||
pool:
|
||||
vmImage: "Ubuntu 16.04"
|
||||
strategy:
|
||||
matrix:
|
||||
Node8:
|
||||
node.version: 8.x
|
||||
Node10:
|
||||
node.version: 10.x
|
||||
Node12:
|
||||
node.version: 12.x
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
displayName: "Install Node"
|
||||
inputs:
|
||||
versionSpec: $(node.version)
|
||||
- script: npm install
|
||||
- task: Npm@1
|
||||
displayName: "npm test"
|
||||
inputs:
|
||||
command: custom
|
||||
verbose: false
|
||||
customCommand: test
|
||||
- task: PublishTestResults@2
|
||||
inputs:
|
||||
testResultsFiles: "**/test-results.xml"
|
||||
testRunTitle: "Test results for JavaScript"
|
||||
- task: PublishCodeCoverageResults@1
|
||||
inputs:
|
||||
codeCoverageTool: Cobertura
|
||||
summaryFileLocation: "$(System.DefaultWorkingDirectory)/**/*coverage.xml"
|
||||
reportDirectory: "$(System.DefaultWorkingDirectory)/**/coverage"
|
||||
- job: Build
|
||||
pool:
|
||||
vmImage: "Ubuntu 16.04"
|
||||
steps:
|
||||
- script: |
|
||||
export TAR_NAME=$(npm pack -q)
|
||||
echo $TAR_NAME
|
||||
echo "##vso[task.setvariable variable=TAR_NAME;isOutput=true;]$TAR_NAME"
|
||||
name: PackArtifacts
|
||||
- task: CopyFiles@2
|
||||
displayName: "Copy Files to: drop"
|
||||
inputs:
|
||||
Contents: "*.tgz"
|
||||
TargetFolder: drop
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: $(Build.SourcesDirectory)/drop
|
||||
- ? ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}
|
||||
: - stage: Release
|
||||
dependsOn: BuildStage
|
||||
jobs:
|
||||
- deployment: PublishToNpm
|
||||
variables:
|
||||
TAR_NAME: $[ stageDependencies.BuildStage.Build.outputs['PackArtifacts.TAR_NAME'] ]
|
||||
pool:
|
||||
vmImage: "Ubuntu 16.04"
|
||||
environment: npm
|
||||
displayName: Publish to NPM
|
||||
strategy:
|
||||
runOnce:
|
||||
deploy:
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "14.x"
|
||||
displayName: "Install Node.js"
|
||||
- script: |
|
||||
cd $(Pipeline.Workspace)/drop
|
||||
export TAR_NAME=$(ls *.tgz)
|
||||
echo === tar
|
||||
echo $TAR_NAME
|
||||
echo === tar
|
||||
npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)
|
||||
npm publish $TAR_NAME --access public --tag ${{ parameters.NpmTag }}
|
||||
npm config delete //registry.npmjs.org/:_authToken
|
||||
displayName: "Publish to NPM"
|
||||
|
|
Загрузка…
Ссылка в новой задаче