Closed RealCoda closed 6 months ago
Hi @RealCoda, your Azure DevOps YAML definition should look like the following, so that the secret is explicitly picked up by Azure DevOps and sent to PR Metrics:
- task: ms-omex.prmetrics.prmetrics.PRMetrics@1
displayName: 'PR Metrics'
env:
PR_METRICS_ACCESS_TOKEN: $(PR_Metrics_Access_Token)
continueOnError: true
The key here is the env
element, for setting the secret within the task.
You can find more information about this at https://github.com/microsoft/PR-Metrics/blob/main/docs/azure-pipelines-task.md.
Could you ensure this is present?
If it is, could you provide the YAML definition you're using so that I can debug further. Thanks!
thx for commenting! I see that one main thing was missing from my description, we use still the classic pipeline mode. (not the pure yaml definition). Interestingly enough, i was not aware that there is a possible difference....
As we can see in the debug log above, there is obviously a difference:
loading SECRET_PR_METRICS_ACCESS_TOKEN
Maybe the classic pipeline is treating things different.(e.g. prefixes automatically with SECRET_ )
I will test this further more and keep you updated.
Hi @RealCoda, thanks for clarifying your scenario.
I believe the key is the "Environment variables" section of the task definition:
For this, the first column would list PR_METRICS_ACCESS_TOKEN
and the second column would be something like $(PR_Metrics_Access_Token)
as far as I recall.
Unfortunately, my test Azure DevOps instance doesn't allow for classic pipelines to be used, so I can't validate this. If this works for you, I'd appreciate if you could let me know so that I can document it at https://github.com/microsoft/PR-Metrics/blob/main/docs/azure-pipelines-task.md for future reference.
Thanks for your input! Well, you were fully right ;-) In classic pipelines i did the following:
=> works perfectly. thx !
Thanks @RealCoda for the info. I've now added this as documentation for future reference via #471.
Summary
PAT Token can not be set to secret to work with PR Metrics in AzureDevops on Premise
Reproduction Steps
Use PR Metrics as a (last) task in some pipeline on Azure DevOps Server On Premise. Add a pipeline variable called "PR_METRICS_ACCESS_TOKEN" to the pipeline and activate "secret" -> leads to error "Could not access the Personal Access Token (PAT). Add 'PR_Metrics_Access_Token' as a secret environment variable." if you deactivate "secret" it works like a charm.
Troubleshooting Undertaken
Additional Information
Versions
Version Azure DevOps Server 2022.1 (AzureDevOpsServer_20231128.1) PR Metrics v1.5.11
Yaml
yaml export file says: (so it was really added) Variable 'PR_METRICS_ACCESS_TOKEN' was defined in the Variables tab
Debug Log