kine / MSDYN365BC_Yaml

Yaml templates for CI/CD for Micrsoft Dynamics 365 Business Central
MIT License
20 stars 18 forks source link

Publish per Tenant App #8

Open antonyotto opened 4 years ago

antonyotto commented 4 years ago

Hi Kine,

thanks for the tools. I'm trying to setup the pipelines to publish App to online sandbox. I received below error in the pipeline and the App is successfully published. Any idea why ?

Thanks.

020-04-23T05:46:24.6853430Z ##[debug]Caught exception from task script. 2020-04-23T05:46:24.6885409Z ##[debug]Error record: 2020-04-23T05:46:24.8596776Z ##[debug]Get-ALAppPublicationStatus : Cannot index into a null array. 2020-04-23T05:46:24.8610876Z ##[debug]At C:\Users\xxxx\Documents\WindowsPowerShell\Modules\NVRAppDevOps\1.0.10\Upload-PerTenantApp.ps1:35 char:23 2020-04-23T05:46:24.8624420Z ##[debug]+ ... $Status = Get-ALAppPublicationStatus -AppId $AppId -AppSecret $AppS ... 2020-04-23T05:46:24.8638220Z ##[debug]+ ~~~~~~~~~~~~~ 2020-04-23T05:46:24.8659418Z ##[debug] + CategoryInfo : InvalidOperation: (:) [Get-ALAppPublicationStatus], RuntimeException 2020-04-23T05:46:24.8673187Z ##[debug] + FullyQualifiedErrorId : NullArray,Get-ALAppPublicationStatus 2020-04-23T05:46:24.8687722Z ##[debug] 2020-04-23T05:46:24.8713010Z ##[debug]Script stack trace: 2020-04-23T05:46:24.8746510Z ##[debug]at Get-ALAppPublicationStatus, C:\Users\xx\Documents\WindowsPowerShell\Modules\NVRAppDevOps\1.0.10\Get-ALAppPublicationStatus.ps1: line 35 2020-04-23T05:46:24.8759320Z ##[debug]at Upload-PerTenantApp, C:\Users\xxx\Documents\WindowsPowerShell\Modules\NVRAppDevOps\1.0.10\Upload-PerTenantApp.ps1: line 35 2020-04-23T05:46:24.8774389Z ##[debug]at , C:\Users\xxx\Downloads\vsts-agent-win-x64-2.165.2_work_tasks\publishbcapppertenant_047393e1-82e4-4d24-8275-237409bb378e\1.0.3\publishtenanttask.ps1: line 27 2020-04-23T05:46:24.8787079Z ##[debug]at , : line 1 2020-04-23T05:46:24.8801035Z ##[debug]at , : line 22 2020-04-23T05:46:24.8821032Z ##[debug]at , : line 18 2020-04-23T05:46:24.8835506Z ##[debug]at , : line 1 2020-04-23T05:46:24.8861615Z ##[debug]Exception: 2020-04-23T05:46:24.8914370Z ##[debug]System.Management.Automation.RuntimeException: Cannot index into a null array. 2020-04-23T05:46:24.8926562Z ##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) 2020-04-23T05:46:24.8943100Z ##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) 2020-04-23T05:46:24.8958536Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2020-04-23T05:46:24.8974329Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2020-04-23T05:46:24.8991809Z ##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) 2020-04-23T05:46:24.9006563Z ##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) 2020-04-23T05:46:24.9018984Z ##[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action1 clause, Object dollarUnderbar, Object inputToProcess) 2020-04-23T05:46:24.9033338Z ##[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing() 2020-04-23T05:46:24.9045536Z ##[debug] at System.Management.Automation.CommandProcessorBase.Complete() 2020-04-23T05:46:24.9331913Z ##[error]Cannot index into a null array. 2020-04-23T05:46:24.9342420Z ##[debug]Processed: ##vso[task.logissue type=error]Cannot index into a null array. 2020-04-23T05:46:24.9344123Z ##[debug]Processed: ##vso[task.complete result=Failed]

kine commented 4 years ago

Hi @antonyotto, have re-read the log you sent and it seems that the problem is, that the call reading the status have not returned anything. It could be some timing issue or I do not know. Will try on my side. Have it worked before? Are you getting this each time or when you re-run the stage it goes trough?

kine commented 4 years ago

Hmm... unable to test on my side, because we have activated MFA on our users accounts to fulfill MS requirements and thus I am unable to publish the apps from pipeline (no support for service accounts yet and the current way doesn't support MFA). This is rendering the Password Grant OAuth unusable (but of course, it was never recommended to use this grant type, but it was only possible way).

antonyotto commented 4 years ago

Hi Kine, Thanks for the reply, this is the first time I used it and I tried few times but the result is the same I will try to run it directly from Powershell and see if it work.

Thanks,

antonyotto commented 4 years ago

It works if I directly use powershell script instead of using task publishbcapppertenant

Upload-PerTenantApp -AppId [xx] -AppSecret [xx] -Tenant [xx] -AppPath "C:\artifact\Default publisher_TestBuild_1.4.0.0.app" -Environment Sandbox -APIVersion v1.0 -Credential $mycreds -WaitForResult Getting OAuth token... Getting companies... Getting uploading extension to company 83b8f35c-fb52-ea11-bb59-00155df3a615 (CRONUS NZ)... Getting last publishing status from company 83b8f35c-fb52-ea11-bb59-00155df3a615... Last status: TestBuild Default publisher 1.4.0.0 InProgress Getting last publishing status from company 83b8f35c-fb52-ea11-bb59-00155df3a615... Last status: TestBuild Default publisher 1.4.0.0 InProgress Getting last publishing status from company 83b8f35c-fb52-ea11-bb59-00155df3a615... Last status: TestBuild Default publisher 1.4.0.0 InProgress Getting last publishing status from company 83b8f35c-fb52-ea11-bb59-00155df3a615... Last status: TestBuild Default publisher 1.4.0.0 Completed

kine commented 4 years ago

Ok. If it works manually and not in pipeline, than double check that all parameters in the pipelines are passed correctly. Are you using your own agent or hosted?

antonyotto commented 4 years ago

I'm using my own agent. it's the same server that I used to run the powershell.

I also try to run the powershell in the pipeline and it works

Sent from Outlook Mobilehttps://aka.ms/blhgte


From: Kamil Sacek notifications@github.com Sent: Friday, April 24, 2020 10:41:20 PM To: kine/MSDYN365BC_Yaml MSDYN365BC_Yaml@noreply.github.com Cc: antonyotto antony.otto@gmail.com; Mention mention@noreply.github.com Subject: Re: [kine/MSDYN365BC_Yaml] Publish per Tenant App (#8)

Ok. If it works manually and not in pipeline, than double check that all parameters in the pipelines are passed correctly. Are you using your own agent or hosted?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kine/MSDYN365BC_Yaml/issues/8#issuecomment-618937643, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJKMR5B2TTHXNUY6A4FKJC3ROFUFBANCNFSM4MOYRYSA.

kine commented 4 years ago

Ok, than the problem must be in the parameters of the step. Could you send me log from the pipeline? I want to see the xxxx-expanded.yaml file from the full logs.

antonyotto commented 4 years ago

Sorry. I have remove the pipeline. I will re-create it and send you the log. thanks