# Node.js # Build a general Node.js project with npm. # Add steps that analyze code, save build artifacts, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript trigger: - master pool: vmImage: 'ubuntu-latest' # [Use this step] To define the vrest-ng-cli version to be downloaded variables: vrest_version: '2.1.0' #vrest-ng-cli version to be downloaded vrest_uversion: '2_1_0' #underscore variant of vrest-ng-cli version steps: - task: NodeTool@0 inputs: versionSpec: '10.x' displayName: 'Install Node.js' # NPM modules should be cached otherwise the install will be too slow # https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops # since the username / user home directory are not available via system variables # (there is even an open question about it) # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops # just use "/home/vsts" for now - task: Cache@2 inputs: key: npm | $(Agent.OS) | package-lock.json path: /home/vsts/.npm restoreKeys: npm | $(Agent.OS) | package-lock.json displayName: Cache NPM packages # [Use this step] vrest-ng-cli binary should be cached - task: Cache@2 inputs: key: '"vrest-ng-cli-$(vrest_version)" | $(Agent.OS)' path: /home/vsts/.cache/vrest restoreKeys: '"vrest-ng-cli-$(vrest_version)" | $(Agent.OS)' displayName: Cache vrest-ng-cli binary # [Use this step] To check whether the binary already exists or not - bash: | if [ -f /home/vsts/.cache/vrest/vrest-ng-cli ]; then echo "##vso[task.setVariable variable=VREST_CLI_EXISTS]true" else echo "##vso[task.setVariable variable=VREST_CLI_EXISTS]false" fi # [Use this step] Download and Install vrest-ng-cli from Github Release # Change version if you would like to install different version # Change OS if you would like to install on different operation system - script: | mkdir -p /home/vsts/.cache/vrest wget -O /home/vsts/.cache/vrest/vrest-ng-cli -q https://github.com/Optimizory/vrest-ng-cli/releases/download/v$(vrest_version)/vrest_ng_cli_linux_$(vrest_uversion) chmod +x /home/vsts/.cache/vrest/vrest-ng-cli displayName: 'Download and Install vrest-ng-cli binary' condition: eq(variables.VREST_CLI_EXISTS, 'false') - script: npm ci displayName: 'Install NPM dependencies' - script: npm run start & displayName: 'Start the application server' # [Use this step] To run vREST NG written Tests - script: /home/vsts/.cache/vrest/vrest-ng-cli run --projectdir=test/ddt-tests --logger=xunit displayName: 'Run vREST NG Tests' # [Use this step] To publish test results to azure pipelines - task: PublishTestResults@2 inputs: testResultsFormat: 'JUnit' testResultsFiles: 'vrest_logs/logs.xml' searchFolder: '$(System.DefaultWorkingDirectory)' # Optional condition: succeededOrFailed()