I'm trying to run my Karate tests in Azure as a pipeline. In order to execute the tests, I need to first grab some environment variables defined in the pipeline itself. I configure these variables in config.js hoping to make them available to use in the tests. Currently, I have something like this:
# azure-pipelines.yml
trigger:
- none
pool:
vmImage: ubuntu-latest
variables:
- name: user_secret
value: "foo"
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
goals: test
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
// config.js
function fn(){
return {
secret: user_secret
};
}
The error I get though is "user_secret" is not defined
I am being told I can debug it locally because the pipeline is providing the values as environment variables, and that I should be able to validate that locally by setting the variables when I run my code. Unfortunately, I can't figure out how to do it. Any help would be greatly appreciated.
Similar to the above example, I also tried to get the variable process.env.user_secret
, but this didn't work for me either.
How can I access Azure variables with my code?