maester
maester copied to clipboard
Error PAth
Hello, i create a Azure Pipeline with Client secret. I have request a free parallelism in Azure DevOps. After i got it, when i run the pipeline, i have this issue:
`Starting: Publish Maester Html Report
Task : Publish Pipeline Artifacts Description : Publish (upload) a file or directory as a named artifact for the current run Version : 1.199.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/publish-pipeline-artifact
Artifact name input: TestResults ##[error]Path does not exist: /home/vsts/work/1/s/test-results Finishing: Publish Maester Html Report `
@kuroboshi this usually indicates that the pipeline failed to run the tests, did you follow this guide to ensure the service principal you are using has correct perms?
https://maester.dev/docs/monitoring/azure-devops
Hello, I use Maester with client secret. I check my Microsoft Graph permissions's, he seems OK.
Use Workload identity federation is required ?
No you can use with workload identity or client secret.
Please share a screenshot of the permissions you have applied to the service principal.
When you talk about service principal, it's this :
Ok thanks that looks fine, do you have Test Plans enabled with licensing as such for test plans?
I request a free parallelism in Azure Devops, watch my email below :
It's possible the path it's trying to publish to does in fact not exist
Artifact name input: TestResults
##[error]Path does not exist: /home/vsts/work/1/s/test-results
What is your folder structure in git for tests? Review the folder structure and ensure that the relative file path the test result publish step is attempting to publish to, is correct based on your git folder structure.
I create manually the folders :
In debug mode, i see the creation of folder :
Ah ha! so if you read that error message, this isn't an issue with the test path at all, as I first suspected your tests are failing to run.
The error message states the variable "userName" is missing. You need to define two variables as per the docs, CLIENTSECRET and CLIENTID, please check you have those set.
I re-add the variables but in the first time i don't check "Keep this value secret", below the result with warning :
In the second run, i just check "Keep this value secret" and i have a error :
Can you share your yaml? The yaml provided in the maester docs doesn't use a variabled called username but your error seems to indicate you are referring to a variable with that name
Hello, here it is
`# Maester Daily Tests
trigger:
- main
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
- main
pool:
vmImage: ubuntu-latest
steps:
- pwsh: |
# Connect to Microsoft Graph
$clientSecret = ConvertTo-SecureString -AsPlainText $env:PS_ClientSecret -Force
[pscredential]$clientSecretCredential = New-Object System.Management.Automation.PSCredential($env:CLIENTID, $clientSecret)
Connect-MgGraph -TenantId $env:TENANTID -ClientSecretCredential $clientSecretCredential
# Install Maester
Install-Module Maester -Force
# Configure test results
$PesterConfiguration = New-PesterConfiguration
$PesterConfiguration.TestResult.Enabled = $true
$PesterConfiguration.TestResult.OutputPath = '$(System.DefaultWorkingDirectory)/test-results/test-results.xml'
# Run Maester tests
Invoke-Maester -Path $(System.DefaultWorkingDirectory)/tests/Maester/ -PesterConfiguration $PesterConfiguration -OutputFolder '$(System.DefaultWorkingDirectory)/test-results'
env:
PS_ClientSecret: $(CLIENTSECRET)
continueOnError: true
displayName: Run Maester Tests
- publish: $(System.DefaultWorkingDirectory)/test-results
artifact: TestResults
displayName: Publish Maester Html Report
- task: PublishTestResults@2
inputs:
testResultsFormat: "NUnit"
testResultsFiles: "**/test-results.xml"
displayName: Publish Pester Test Results`
So this yaml looks okay.
Can you confirm that you have a variable named CLIENTID defined in the Variables page?
The most likely cause of the error is the client id is not being passed through. You can try adding a Write-Host $env:CLIENTID
to verify if the id is being passed into PowerShell.
Hello,
The problem doesnt appair when the variables is not hidden :
I'm not sure, but when I check the "Keep this value secret" box, I must be missing something for the mapping.
For your information i doesnt see the client id with "Write-Host $env:CLIENTID" when i check the "Keep this value secret"
Otherwise I have the report but I still have an error :
if your using secret vars you will need to change the pwsh task to the full task and set the secret pipeline variable as a environment variable in the script
- task: PowerShell@2
env:
SECRETVALUE: $(SECRETVARNAMEHERE)
inputs:
targetType: inline
script: |
{Your pwsh script here}
You can then use env vars as usual to access the secret variable. Sorry if my example isnt the best it is late!
Please see Set secret variables for reference
@kuroboshi Did you manage to get to the bottom of this?
Hello, sorry i was in holidays. @DrPye My pwsh script is :
Invoke-Maester -Path $(System.DefaultWorkingDirectory)/tests/Maester/ -PesterConfiguration $PesterConfiguration -OutputFolder '$(System.DefaultWorkingDirectory)/test-results'
@kuroboshi only the ClientSecret needs to have the secret hidden. So what you have done above is correct and has fixed the issue.
Closing inactive thread.