0

While pushing a release through code-push extension on VSTS i am getting the following error unable to know why!

enter image description here

Tried one of the below solution as adding a variable named as "Build.SourceDirectory" in your build definition and getting the following error log

enter image description here

2017-11-17T09:13:07.6795222Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
2017-11-17T09:13:07.6795222Z ZUMOAPPNAME@1.0.0 d:\a\3\s
2017-11-17T09:13:07.6795222Z `-- (empty)
2017-11-17T09:13:07.6795222Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2017-11-17T09:13:07.6795222Z 
2017-11-17T09:13:07.6835014Z npm WARN ZUMOAPPNAME@1.0.0 No description
2017-11-17T09:13:07.8445206Z npm WARN ZUMOAPPNAME@1.0.0 No license field.
2017-11-17T09:13:07.8465194Z npm ERR! Windows_NT 10.0.14393
2017-11-17T09:13:07.8475041Z npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cordova"
2017-11-17T09:13:07.8475041Z npm ERR! node v6.10.0
2017-11-17T09:13:07.8475041Z npm ERR! npm  v3.10.10
2017-11-17T09:13:07.8475041Z npm ERR! path d:\a\3\s\node_modules\cordova\node_modules\.bin\acorn.cmd
2017-11-17T09:13:07.8475041Z npm ERR! code EEXIST
2017-11-17T09:13:07.8475041Z 
2017-11-17T09:13:07.8475041Z npm ERR! Refusing to delete d:\a\3\s\node_modules\cordova\node_modules\.bin\acorn.cmd: ..\acorn\bin\acorn symlink target is not controlled by npm d:\a\3\s\node_modules\cordova\node_modules\acorn
2017-11-17T09:13:07.8475041Z npm ERR! File exists: d:\a\3\s\node_modules\cordova\node_modules\.bin\acorn.cmd
2017-11-17T09:13:07.8475041Z npm ERR! Move it away, and try again.
2017-11-17T09:13:07.8475041Z 
2017-11-17T09:13:07.8475041Z npm ERR! Please include the following file with any support request:
2017-11-17T09:13:07.8475041Z npm ERR!     d:\a\3\s\Client Components\Main\Source\vr9-11\npm-debug.log
2017-11-17T09:13:07.8475041Z npm ERR! code 1
2017-11-17T09:13:07.9305055Z ##[debug]load strings from: d:\a\_tasks\CodePushReleaseCordova_f5990527-f512-4c14-9f8e-1254240dc3cb\1.0.5\node_modules\vsts-task-lib\lib.json
2017-11-17T09:13:07.9325060Z Unhandled: Command failed: npm install cordova
2017-11-17T09:13:07.9325060Z ##[debug]load loc strings from: d:\a\_tasks\CodePushReleaseCordova_f5990527-f512-4c14-9f8e-1254240dc3cb\1.0.5\node_modules\vsts-task-lib\Strings\resources.resjson\en-US\resources.resjson
2017-11-17T09:13:07.9325060Z ##[debug]task result: Failed
2017-11-17T09:13:07.9365053Z ##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: Command failed: npm install cordova

The log file can be seen at the following link: https://drive.google.com/open?id=1OC49xlDOEQekO9gqdrj0NQCMPz8onTRX

Tried the solution suggested by Eddie(removing files of bower and node modules as they are regenerated while building) and got the following error.

2017-11-21T06:39:48.8214252Z ##[debug]Finished Building Command: node d:\a\_tasks\CodePushReleaseCordova_f5990527-f512-4c14-9f8e-1254240dc3cb\1.0.5\node_modules\code-push-cli\script\cli release-cordova "Syngenta_Visit_Report1" "android" --deploymentName "Staging" --rollout "100%"
2017-11-21T06:39:48.8254247Z ##[debug]Attempting execution of command: node d:\a\_tasks\CodePushReleaseCordova_f5990527-f512-4c14-9f8e-1254240dc3cb\1.0.5\node_modules\code-push-cli\script\cli release-cordova "Syngenta_Visit_Report1" "android" --deploymentName "Staging" --rollout "100%"
2017-11-21T06:39:49.6774368Z Running "cordova prepare" command:
2017-11-21T06:39:49.6774368Z 
2017-11-21T06:39:49.6874306Z 'cordova' is not recognized as an internal or external command,
2017-11-21T06:39:49.6904319Z operable program or batch file.
2017-11-21T06:39:49.6924371Z [Error]  Unable to prepare project. Please ensure that this is a Cordova project and that platform "android" was added with "cordova platform add android"
2017-11-21T06:39:49.7014305Z ##[debug]Finished Building Command: node d:\a\_tasks\CodePushReleaseCordova_f5990527-f512-4c14-9f8e-1254240dc3cb\1.0.5\node_modules\code-push-cli\script\cli logout
2017-11-21T06:39:50.5584321Z ##[debug]task result: Failed
2017-11-21T06:39:50.5624318Z ##[debug]Processed: ##vso[task.complete result=Failed;]Command failed: release-cordova
2017-11-21T06:39:50.5624318Z Command failed: release-cordova

The Following error while trying for Eddie's solution

  • What troubleshooting steps have you taken so far? – Daniel Mann Nov 08 '17 at 16:02
  • i have tried deleting the android folder from platforms, but that did not work for me – Krishna Lahoti Nov 09 '17 at 05:16
  • Are you using the this [CodePush](https://marketplace.visualstudio.com/items?itemName=ms-vsclient.code-push#overview) extension? And could you enable verbose output of build logs to get more detail info for troubleshoting? How to please follow this tutorial: http://blog.devmatter.com/enabling-verbose-output-in-team-foundation-build-logs/ – PatrickLu-MSFT Nov 09 '17 at 09:56
  • Yeah i am using the CodePush extension and also enabled the variable System,debug to true for troubleshooting – Krishna Lahoti Nov 13 '17 at 06:07
  • also I have edited the question with more detailed log – Krishna Lahoti Nov 13 '17 at 06:16

2 Answers2

1

The task runs "cordova prepare" command from the root of Build.SourcesDirectory folder like "d:\a\3\s". I suspect that your code files are placed in a sub folder like "d:\a\3\s\yourappname" which cause the command cannot find the project. However, there isn't any option to specify the project directory in the task.

As a workaround, you can add a variable named as "Build.SourceDirectory" in your build definition like below: enter image description here

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • tried the above workaround but getting an error named-"Unable to expand variable 'Build.SourceDirectory'. A cyclical reference was detected. Evaluating condition for step: 'Post Job Cleanup'" – Krishna Lahoti Nov 17 '17 at 06:13
  • i have updated the question with the trial of your solution and the error log i got after i tried the above solution – Krishna Lahoti Nov 17 '17 at 07:09
  • @KrishnaLahoti Remove "\$" from the variable value. – Eddie Chen - MSFT Nov 17 '17 at 07:23
  • tried removing the "\$" from the variable value but still the error is same and updated the screenshot in the question which depicts the variable value – Krishna Lahoti Nov 17 '17 at 07:46
  • @KrishnaLahoti Can you check from the logs to see if the "Build.SourceDirectory" points to the correct path after remove "\$". Or you can share the entire build logs for us to check. – Eddie Chen - MSFT Nov 17 '17 at 08:29
  • Yes, got the mistake that i used "$(Build.SourceDirectory)\\..." instead of "$(Build.SourcesDirectory)\\..." and rebuilt the project again but now getting the error that "Command failed: npm install cordova" can u pls help? – Krishna Lahoti Nov 17 '17 at 09:24
  • also i have edited the question with the error log i got – Krishna Lahoti Nov 17 '17 at 09:26
  • does the above log help you to debug the error? Pls do revisit the question i have completely updated the question – Krishna Lahoti Nov 20 '17 at 05:37
  • @KrishnaLahoti No, It didn't include the logs for "Get Sources" step. With the logs for that steps, we can check the detailed path for your project. You can click "Download all logs as zip" button to download the entire logs. If you cannot share it public, please drop me an email: eddche at microsoft.com – Eddie Chen - MSFT Nov 20 '17 at 06:11
  • I have dropped a mail to you and also updated the question with the log file of the build, hope that might help you debug the error and come up with a solution, thanks in advance! – Krishna Lahoti Nov 20 '17 at 06:20
  • According to the logs, you also checked in the "bower_components" folder and "node_modules" folder into the version control which is not recommended. Usually, you should only check in your code files and package.json file to version control. When you download the code to a new machine or during the build process, use bower install and npm install to install these packages. – Eddie Chen - MSFT Nov 21 '17 at 01:50
  • Thanks a lot Eddie, i will try deleting those files and making a successful deployment. – Krishna Lahoti Nov 21 '17 at 06:11
  • Still getting errors Eddie, i have updated the question with the lates log and screenshot of the same, pls do get back if you could find the solution, Thanks – Krishna Lahoti Nov 21 '17 at 06:53
0

First make sure that the folder you check in does not have any files inside node_modules folder, presence of which the hosted agent may not be able to delete the files and the tasks fails The hosted agent will download the files needed on it's own by checking the JSON files.

In order to trouble shooting for this error: Please add two tasks before CodePush task:

1) Add npm task with this setting

https://drive.google.com/open?id=1H4bWAMruzfOs90xOLxgjadAd7DihaVH4

2)After npm task, add Command Line task with below setting

https://drive.google.com/open?id=1bxd54kVgW4zGRwhsH_JKz_cjc1wYZ-No

Then check if the Cordova command can execute correctly

Then if you have specified the variable Build.SourceDirectory

as $(Build.SourcesDirectory)\path to your app

remove it (the variable) as you have already specified the path in GET SOURCES

You do not need to add the “Build.SourceDirectory” variable in this condition. And now, you specified the working directory to “d:\a\3\s\app path” which should not exist on the build agent, but the task didn’t report that error.

The task indicated that it cannot find the config.xml since the file exist under “d:\a\3\s” rather than “d:\a\3\s\app path”.

Thus remove the “Build.SourceDirectory” variable and run the build to check

The above steps should work for the given problem

Thanks Eddie Chen for the help