colindembovsky / cols-agent-tasks

Colin's ALM Corner Custom Build Tasks
MIT License
83 stars 65 forks source link

Cannot read property 'toLowerCase' of undefined #45

Closed xiangyan99 closed 7 years ago

xiangyan99 commented 7 years ago

Here is the log

2017-02-09T21:35:07.0855146Z ##[section]Starting: Replace tokens in BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/. 2017-02-09T21:35:07.1167734Z ============================================================================== 2017-02-09T21:35:07.1167734Z Task : Replace Tokens 2017-02-09T21:35:07.1167734Z Description : Replaces tokens in a file using RegEx. Values come from any variable defined in the current Environment. 2017-02-09T21:35:07.1167734Z Version : 1.1.63 2017-02-09T21:35:07.1167734Z Author : Colin Dembovsky (colinsalmcorner.com) 2017-02-09T21:35:07.1167734Z Help : More Information 2017-02-09T21:35:07.1167734Z ============================================================================== 2017-02-09T21:35:07.3355787Z ##[debug]agent.workFolder=C:\buildagent3_work 2017-02-09T21:35:07.3355787Z ##[debug]loading inputs and endpoints 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_3f54bb33-193e-45f4-a2af-83b76d02c66b 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_3f54bb33-193e-45f4-a2af-83b76d02c66b_ACCESSTOKEN 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SCHEME_3f54bb33-193e-45f4-a2af-83b76d02c66b 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION 2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION 2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_FILEPATTERN 2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_SECRETTOKENS 2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_SOURCEPATH 2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_TOKENREGEX 2017-02-09T21:35:07.3355787Z ##[debug]loaded 10 2017-02-09T21:35:07.3512078Z ##[debug]Starting Replace Tokens task 2017-02-09T21:35:07.3512078Z ##[debug]sourcePath=C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core\ 2017-02-09T21:35:07.3512078Z ##[debug]check path : C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core\ 2017-02-09T21:35:07.3512078Z ##[debug]filePattern=GlobalSettings.cs 2017-02-09T21:35:07.3512078Z ##[debug]tokenRegex=YOUR_PROFILE_SERVICE 2017-02-09T21:35:07.3512078Z ##[debug]secretTokens=bikesharing-services-profileseh7q7oryxj6yk 2017-02-09T21:35:07.3512078Z ##[debug]secretTokens: found [0] tokens 2017-02-09T21:35:07.3668362Z ##[debug]sourcePath: [C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core] 2017-02-09T21:35:07.3668362Z ##[debug]filePattern: [GlobalSettings.cs] 2017-02-09T21:35:07.3668362Z ##[debug]tokenRegex: [YOUR_PROFILE_SERVICE] 2017-02-09T21:35:07.3668362Z ##[debug]Using [GlobalSettings.cs] as filePattern 2017-02-09T21:35:07.3668362Z ##[debug]glob C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core\GlobalSettings.cs 2017-02-09T21:35:07.3668362Z ##[debug]found 1 matches 2017-02-09T21:35:07.3668362Z ##[debug]matches: 2017-02-09T21:35:07.3668362Z ##[debug]C:/buildagent3/_work/5/s/BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/GlobalSettings.cs 2017-02-09T21:35:07.3668362Z Starting regex replacement in [C:/buildagent3/_work/5/s/BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/GlobalSettings.cs] 2017-02-09T21:35:07.3668362Z ##[debug]task result: Failed 2017-02-09T21:35:07.3824661Z ##[error]Cannot read property 'toLowerCase' of undefined 2017-02-09T21:35:07.3824661Z ##[debug]Processed: ##vso[task.issue type=error;]Cannot read property 'toLowerCase' of undefined 2017-02-09T21:35:07.3824661Z ##[debug]Processed: ##vso[task.complete result=Failed;]Cannot read property 'toLowerCase' of undefined 2017-02-09T21:35:07.3824661Z ##[debug]Leaving Replace Tokens task

colindembovsky commented 7 years ago

Hi @xiangyan99 - it looks like you're passing in a secret variable (bikesharing-services-profileseh7q7oryxj6yk)? Is that correct? This setting should only be used for older versions of the agent (so not on VSTS at all - just define it as a secret in the variables section). If you're on an older version of the agent and need to specify the secrets, then they should contain a ; separator - so it should be more like bikeshareing-services-profile;seh7q7oryxj6yk.

xiangyan99 commented 7 years ago

@colindembovsky In fact, this is the backend URL for my app. I don't want to hard code the backend URL in the code so I use a token here and expect if I want to switch the backend, I don't need to modify the code. I only need to update the build definition instead. Thanks.