happytal / substitute-variables

Azure DevOps task for substituting variables in plain JSON and YAML files
MIT License
1 stars 0 forks source link

##[error]File application.yml does not exist #11

Closed vijaypatnana closed 2 years ago

vijaypatnana commented 2 years ago

Hello,

I have the application configuration yaml file as published artifact. I have this substitute variable task right after the download artifacts, I am not sure why it is not picking up the file as input. Please advise. Thanks in advance!

here is the complete error details -

2022-02-09T21:41:16.6019970Z ##[debug]Evaluating condition for step: 'Substitute variables'
2022-02-09T21:41:16.6022024Z ##[debug]Evaluating: succeeded()
2022-02-09T21:41:16.6022514Z ##[debug]Evaluating succeeded:
2022-02-09T21:41:16.6023759Z ##[debug]=> True
2022-02-09T21:41:16.6024392Z ##[debug]Result: True
2022-02-09T21:41:16.6025371Z ##[section]Starting: Substitute variables
2022-02-09T21:41:16.6034022Z ==============================================================================
2022-02-09T21:41:16.6034323Z Task         : Substitute Variables
2022-02-09T21:41:16.6034583Z Description  : Apply variable substitution to JSON and YAML files.
2022-02-09T21:41:16.6035061Z Version      : 1.2.1
2022-02-09T21:41:16.6035245Z Author       : happytal
2022-02-09T21:41:16.6036194Z Help         : https://github.com/happytal/substitute-variables
2022-02-09T21:41:16.6036511Z ==============================================================================
2022-02-09T21:41:16.6210929Z ##[debug]Using node path: /home/vpatnana/myagent/externals/node10/bin/node
2022-02-09T21:41:16.9877877Z ##[debug]agent.TempDirectory=/home/vpatnana/myagent/_work/_temp
2022-02-09T21:41:16.9904619Z ##[debug]loading inputs and endpoints
2022-02-09T21:41:16.9917105Z ##[debug]loading INPUT_FILES
2022-02-09T21:41:16.9944388Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2022-02-09T21:41:16.9950791Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2022-02-09T21:41:16.9955187Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2022-02-09T21:41:16.9966709Z ##[debug]loaded 4
2022-02-09T21:41:16.9967950Z ##[debug]Agent.ProxyUrl=undefined
2022-02-09T21:41:16.9969092Z ##[debug]Agent.CAInfo=undefined
2022-02-09T21:41:16.9970258Z ##[debug]Agent.ClientCert=undefined
2022-02-09T21:41:16.9972111Z ##[debug]Agent.SkipCertValidation=undefined
2022-02-09T21:41:16.9974314Z ##[debug]files=application.yml
2022-02-09T21:41:16.9977070Z ##[debug]task result: Failed
2022-02-09T21:41:17.0009146Z ##[error]File application.yml does not exist
2022-02-09T21:41:17.0018922Z ##[debug]Processed: ##vso[task.issue type=error;]File application.yml does not exist
2022-02-09T21:41:17.0021821Z ##[debug]Processed: ##vso[task.complete result=Failed;]File application.yml does not exist
2022-02-09T21:41:17.0028679Z ##[section]Finishing: Substitute variables
fhervieux commented 2 years ago

The task cannot find the specified file. By default it will look for it in the working directory. Is it not there you can specify an absolute path using variables.

For example if it is a downloaded artifact it might be in $(Pipeline.Workspace) so you could use $(Pipeline.Workspace)/application.yml as input. Note that I am not sure this is the right path for you, it depends where your file actually is but this is the idea.

vijaypatnana commented 2 years ago

My artifacts and application.yml are located here - /home/vpatnana/myagent/_work/r1/a/_Aplus/. I guess the substitute task is looking at here - /home/vpatnana/myagent/_work/temp. What is the default location of this extension?

As you suggested, I have tried this - $(Pipeline.Workspace)/application.yml as input and getting the same error.

vijaypatnana commented 2 years ago

Fixed the path issue, Now the task found my application.yml file, but I am seeing different error now.

2022-02-11T17:23:51.8813853Z ##[debug]files=/home/vpatnana/myagent/_work/r1/a/_Aplus/drop/application.yml 2022-02-11T17:23:51.8820820Z Substituting variables in /home/vpatnana/myagent/_work/r1/a/_Aplus/drop/application.yml 2022-02-11T17:23:51.8897680Z { Error: Line 5: Unexpected token ILLEGAL 2022-02-11T17:23:51.8899712Z ##[debug]File could not be parsed as JSON: Line 5: Unexpected token ILLEGAL 2022-02-11T17:23:51.8906467Z at ErrorHandler.constructError (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:5012:22) 2022-02-11T17:23:51.8909228Z at ErrorHandler.createError (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:5028:27) 2022-02-11T17:23:51.8911086Z at ErrorHandler.throwError (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:5035:21) 2022-02-11T17:23:51.8912452Z at Scanner.throwUnexpectedToken (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:5164:35) 2022-02-11T17:23:51.8913718Z at Scanner.scanNumericLiteral (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:5837:19) 2022-02-11T17:23:51.8915115Z at Scanner.lex (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:6251:26) 2022-02-11T17:23:51.8917866Z at Tokenizer.getNextToken (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:6675:84) 2022-02-11T17:23:51.8920526Z at Object.tokenize (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/esprima/dist/esprima.js:154:36) 2022-02-11T17:23:51.8922644Z at Object.parseRegEx (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/decomment/lib/utils.js:37:13) 2022-02-11T17:23:51.8924235Z at parser (/home/vpatnana/myagent/_work/_tasks/SubstituteVariables_8472daf1-88bc-49e1-9bd6-d1591c8d20dc/1.2.1/node_modules/decomment/lib/parser.js:36:27) 2022-02-11T17:23:51.8925414Z index: 121, 2022-02-11T17:23:51.8926011Z lineNumber: 5, 2022-02-11T17:23:51.8927254Z description: 'Unexpected token ILLEGAL' }

fhervieux commented 2 years ago

Glad you fixed the path issue.

There was a regression in the last version that caused this error to show up in the logs when using YAML files. The task still worked as expected though. I published version 1.2.2 to fix that. Now the logs should be clean even for YAML files.