The plugin can't find files and generate HTML report on Azure DevOps
Azure Devops plugin - https://marketplace.visualstudio.com/items?itemName=MaciejMaciejewski.azure-pipelines-cucumber
azure-pipelines.yml
jobs:
# Build Electron
- job: UserAcceptanceTest
displayName: E2E-Tests
pool:
name: ado-win-pool
timeoutInMinutes: 120
steps:
- task: CopyFiles#2
inputs:
sourceFolder: $(Build.SourcesDirectory)
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact#1
displayName: 'Publishing build artifacts'
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
- task: NodeTool#0
displayName: 'Install Node 12.x'
inputs:
versionSpec: 12.x
- task: PublishCucumberReport#1
displayName: 'Publish Cucumber Report'
inputs:
jsonDir: target/results/cucumber/
outputPath: target/results/cucumber/
Actual:
Found 0 matching C:/agent/_work/13/s/target/results/cucumber pattern
##[warning]Error: Not found outputPath: C:\agent\_work\13\s\target\results\cucumber
Finishing: Publish Cucumber Report
Expected:
Found cucumber JSON file.
In your case, the problem is in the path provided for the cucumber report.
It should be a path to the folder with cucumber reports in json format, but not to some particular json.
So, the correct snippet in yaml would be:
- task: PublishCucumberReport#1
displayName: 'Publish Cucumber Report'
inputs:
jsonDir: target/results/cucumber/
outputPath: target/results/cucumber/
In above yaml pipeline, you didnot have the step to run your cucumber test to generate the cucumber JSON file.
If the cucumber JSON file is already existing in your repo. Then the error from PublishCucumberReport task is because the directory target/results/cucumber doesnot exist in your repo.
Then You need to check where the cucumber JSON file is located in your repo and specify the correct path for PublishCucumberReport task.
If there is no cucumber JSON fileexisting in your repo. You should add steps in the yaml pipeline to run your tests.
If you have your test scripts configured in the package.json file, like below(report folder must exist in the repo):
You can just run the npm test to execute your tests and generate the json report in the report folder. See below;
steps:
- task: NodeTool#0
displayName: 'Install Node 12.x'
inputs:
versionSpec: 12.x
- script: |
npm install
npm test
displayName: 'Run tests'
- task: PublishCucumberReport#1
inputs:
jsonDir: report
outputPath: report
If there is no test script defined in your package.json file. You can run the cucumber-js command in the yaml pipeline to generate the json file. See below:
- script: |
#npm install cucumber
npm install
./node_modules/.bin/cucumber-js features -f json:report/cucumber_report.json
displayName: 'Run tests'
Related
Hiall,
I developed a ui test with playwright.
I run this in azure pipeline, when a test is pass, everything is OK, the
steps:
run test - pass
publish artifact - pass
post job - pass
but when i add an error to the test -
await expect(activitiesHeader).toHaveClass("goodclass badclass")
I get an error in pipeline log, it is ok, and reach the timeout too
but the pipeline is stuck in run test step (so the next steps never execute)
my yaml:
task: NodeTool#0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
script: npm install
script: npm ci
script: npm install #playwright/test
script: npx playwright install --with-deps
displayName: "Install browser dependencies"
script: npm i playwright-chromium
displayName: "run the test"
condition: succeeded()
script: npm run azurelogin
task: CopyFiles#1
condition: succeededOrFailed() # Run task even if previous ones fail
inputs:
#leave it empty, the copying is done from the root folder
#sourceFolder: '$(Build.SourcesDirectory)/_daniavander_hydro-test/playwright-report'
contents: |
playwright-report/**
screenshot/**
test-results/**
targetFolder: '$(Build.ArtifactStagingDirectory)'
task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
I've been followings microsoft's documentation for the new yml ci-cd datafactory deployment. However, I keep getting a validation error when trying to implement CI/CD pipelines for Azure Data Factory with a yml file, after the installation of npm.
I get the following error message:
Error: Command failed: node /home/vsts/work/1/s/DataFactories/joaov1/build/downloads/main.js validate /home/vsts/work/1/s DataFactories/joaov1/subscriptions/000000-0000-0000-0000-864d437bd294/resourceGroups/rg-hi-joaov1-dev/providers/Microsoft.DataFactory/factories/adf-client-joaov1-dev
Execution finished....
Found npm debug log, make sure the path matches with the one in npm's output: /home/vsts/.npm/_logs/2021-12-01T21_20_55_974Z-debug.log
I'm quite confident that it is a an issue with the path, but after hours of research online I still can't get it to work...
My file structure is the following:
And my code is as follows:
# Sample YAML file to validate and export an ARM template into a build artifact
# Requires a package.json file located in the target repository
trigger:
- master
# parameters:
# - name: 'dev'
# - name: 'test'
# - name: 'prod'
pool:
vmImage: 'ubuntu-latest'
steps:
# Installs Node and the npm packages saved in your package.json file in the build
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm#1
inputs:
command: 'install'
workingDir: '$(Build.Repository.LocalPath)/DataFactories/joaov1/build' #replace with the package.json folder
verbose: true
displayName: 'Install npm package'
# Validates all of the Data Factory resources in the repository. You'll get the same validation errors as when "Validate All" is selected.
# Enter the appropriate subscription and name for the source factory.
- task: Npm#1
inputs:
command: 'custom'
workingDir: '$(Build.Repository.LocalPath)/DataFactories/joaov1/build' #replace with the package.json folder
customCommand: 'run build validate $(Build.Repository.LocalPath)/DataFactories/joaov1/subscriptions/000000-0000-0000-974d-864d437bd294/resourceGroups/rg-hi-joaov1-dev/providers/Microsoft.DataFactory/factories/adf-client-joaov1-dev'
displayName: 'Validate'
# Validate and then generate the ARM template into the destination folder, which is the same as selecting "Publish" from the UX.
# The ARM template generated isn't published to the live version of the factory. Deployment should be done by using a CI/CD pipeline.
- task: Npm#1
inputs:
command: 'custom'
workingDir: '$(Build.Repository.LocalPath)/DataFactories/joaov1/build' #replace with the package.json folder
customCommand: 'run build export $(Build.Repository.LocalPath)/DataFactories/joaov1/subscriptions/000000-0000-4aab-974d-864d437bd294/resourceGroups/rg-hi-joaov1-dev/providers/Microsoft.DataFactory/factories/adf-client-joaov1-dev "ArmTemplate"'
displayName: 'Validate and Generate ARM template'
# Publish the artifact to be used as a source for a release pipeline.
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Build.Repository.LocalPath)/DataFactories/joaov1/build/ArmTemplate' #replace with the package.json folder
artifact: 'ArmTemplates'
publishLocation: 'pipeline'
Any help would be great,
Thank you so much,
Joao
You ADF Build tasks Node version should be changed from 10.X to 14.X.
- task: NodeTool#0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
I am trying to integrate storybook/chromatic into my azure pipeline, however i am getting the following error:
/home/vsts/work/_temp/60ae6370-8818-4ab7-a2d8-f4a0443fadf9.sh: line 1: --project-token=${project_token}: bad substitution
I followed this https://www.chromatic.com/docs/azure-pipelines
I did obviously put my project token where it was needed.
Based on the error message, it seems that this issue comes from a script format or symbol.
I have tested the YAML sample from the link you shared and it can work fine.
Here are my steps, you can refer to them.
Step1 : Set the variable CHROMATIC_PROJECT_TOKEN
Step2: Run the YAML sample:
stages:
- stage: Test
displayName: Chromatic Testing
# Job list
jobs:
- job: Chromatic_Deploy
displayName: Install packages and publishes to Chromatic
steps:
- task: NodeTool#0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'
- task: Npm#1
inputs:
command: 'install'
workingDir: '$(build.sourcesdirectory)'
- task: CmdLine#2
displayName: Publish to Chromatic
inputs:
script: npx chromatic --project-token=${CHROMATIC_PROJECT_TOKEN}
Here is my result:
You can also try to use --project-token=$(CHROMATIC_PROJECT_TOKEN) in the YAML sample.
I have created the below YAML file with the PublishTestResults task to display the mocha test results in Azure DevOps portal
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.14.1'
displayName: 'Install Node.js'
- script: |
npm install
mocha test --reporter mocha-junit-reporter
npm test
displayName: 'npm install and test'
- task: PublishTestResults#2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/TEST-RESULTS.xml'
- task: ArchiveFiles#2
displayName: 'Archive $(System.DefaultWorkingDirectory)'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/node.zip'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
but whenever I run the build I am getting the following warning
"No test result files matching **/TEST-RESULTS.xml were found."
The main motive is to display the mocha test results separately in a dashboard or a test tab. So that we don't have to check the test task in build process to see the test results.
I encountered same issue,
After trying bunch of things could solve it as below.
Step 1. Update package.json
Include in scripts section:
"test": "cross-env CI=true react-scripts test --env=jsdom
--testPathIgnorePatterns=assets --reporters=default --reporters=jest-junit"
Include below in jest config or jest section in package.json
"jest-junit": {
"suiteNameTemplate": "{filepath}",
"outputDirectory": ".",
"outputName": "junit.xml"
}
Run npm run test locally and see if junit.xml is created.
Step 2. In Azure Pipeline YAML file
Include an Npm task with custom command as below
- task: Npm#1
displayName: 'Run Tests'
inputs:
command: 'custom'
workingDir: "folder where your package.json exists"
customCommand: 'test'
Task to publish Results
- task: PublishTestResults#2
displayName: 'Publish Unit Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/junit.xml'
mergeTestResults: true
failTaskOnFailedTests: true
testRunTitle: 'React App Test'
Publish Test Results
To try to make it short, I have a React application that's build on Azure DevOps Build Pipeline like so
trigger:
- Release
queue:
name: Hosted
demands: npm
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm ci
npm run build
displayName: 'Do npm ci and build'
This does what the build would do locally too. Locally the results of build go to build directory (unzipped).
Now when I try to create release pipeline there isn't an artifact to be found using Azure Deploy Web Service task.
If I try to add PublishPipelineArtifact#0 to the build pipeline to create a publication, the YAML editor just tells string does not match pattern... and doesn't let save the definition.
I suppose I should zip the contents of the generated build directory, but what would be the right way? Also, Is using the Azure App Service Deploy task the right way to deploy Azure WebApp? It works for ASP.NET Core apps so it finds the code drop artefact (zipped) and deploys it.
<edit: Adding
- task: PublishPipelineArtifact#0
inputs:
artifactName: 'drop'
targetPath: '$(Build.ArtifactStagingDirectory)/build'
Can actually be saved and the build run. Though it errors with
2019-01-25T22:42:27.6896518Z ##[section]Starting:
PublishPipelineArtifact 2019-01-25T22:42:27.6898909Z
============================================================================== 2019-01-25T22:42:27.6898962Z Task : Publish Pipeline Artifact
2019-01-25T22:42:27.6899006Z Description : Publish Pipeline Artifact
2019-01-25T22:42:27.6899034Z Version : 0.139.0
2019-01-25T22:42:27.6899062Z Author : Microsoft Corporation
2019-01-25T22:42:27.6899090Z Help : Publish a local directory
or file as a named artifact for the current pipeline.
2019-01-25T22:42:27.6899137Z
============================================================================== 2019-01-25T22:42:28.0499917Z ##[error]Path not exist: D:\a\1\a\build
2019-01-25T22:42:28.0708878Z ##[section]Finishing:
PublishPipelineArtifact
< edit 2: It appears removing the /build does the trick. Feels a tad odd since this is what's produced locally. It doesn't produce a zip file which is expected by the release job, namely Azure App Service Deploy.
Have to examine this problem later today (two o'clock at night here).
There was another problem: The script ran only npm ci and didn't run the building part. Separating it to two different steps made the difference. It appears PublishPipelineArtifact#0 in this case isn't an ideal option if I'd like to have the results as zipped to the staging area.
A currently working solution seem to be
resources:
- repo: self
trigger:
- Release
queue:
name: Hosted
demands: npm
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm ci
displayName: 'npm ci'
- script: |
npm run build
displayName: 'npm run build'
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/artifact.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
Maybe this can be simplified, but works for now and is flexible, it feels.