I am trying to run a node application in azure devops and I am struggling with the following issue. I need to set an environment variable that is picked up with the code, but it looks like I am no hitting the point
Yaml:
pool:
vmImage: 'ubuntu-latest'
parameters:
- name: VERBOSE
displayName: 'Verbose'
type: boolean
default: false
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.16.x'
displayName: 'Install Node.js'
- task: Npm@1
inputs:
command: install
workingDir: '$(Build.SourcesDirectory)/pipelines/schemas'
verbose: false
customRegistry: useNpmrc
displayName: 'Install npm'
- task: CmdLine@2
env:
VERBOSE: ${{ parameters.VERBOSE }}
inputs:
script: 'node app.js'
workingDirectory: '$(Build.SourcesDirectory)/pipelines/schemas'
displayName: 'Run app.js'
at the first line of app.js I set a console.log(process.env["VERBOSE"]), but nothing is displayed.
Do you know what I am missing?
2
Answers
I would first check whether it fails on assignment or evaluation.
If you change the default parameter value, is it reflected?
If not, fix that first. If yes, then start figuring out how to assign the parameter correctly. Right now it’s impossible to tell which of these needs fixing.
This is the YAML on my side:
My repo structure:
I can get the value successfully:
Try to use the above simply demo, could the value appear on your side?