microsoft / coe-starter-kit

Other
748 stars 220 forks source link

[ALM Accelerator - BUG]: Update Deployment Settings fails to save #2006

Closed ChrisL66 closed 2 years ago

ChrisL66 commented 2 years ago

Describe the issue

More of a question Just setting the system up, and the pipeline fails on this task I have added some echo statements to debug and it seems to get the setting from cat_usersettings/cat_data (?) table. Those were set to "[]", I have tried setting the value to a dummy value, but still having issues updating the settings Does someone have an example of what should be in the field in Power Platform or why the update would be failing here. error is Exception setting "variables": "The property 'variables' cannot be found on this object. Verify that the property exists and can be set."

Task fails found 0 vulnerabilities info: Branch start info: Setup branch info: Using supplied access token buildDefinitionResourceUrl: https://........visualstudio.com/......./_apis/build/definitions?name=deploy-*-ALM_test&includeAllProperties=true&api-version=6.0 buildDefinitionResponseResults1: set build definition variables definitionId: 33 newBuildDefinitionVariables: configurationVariable: #{team.samplegroupteamname.aadSecurityGroupId}# found: False newEnvironmentConfig: @{original=System.Collections.Generic.Dictionary2[System.String,System.Object]; logicalname=cat_usersetting; cat_usersettingid=.....; ReturnProperty_EntityName=cat_usersetting; EntityReference=Microsoft.Xrm.Sdk.EntityReference; cat_data_Property=[cat_data, [{"EnvironmentUrl":"[https://......crm3.dynamics.com/"}]];](https://.......crm3.dynamics.com/%22%7D]];) ReturnProperty_Id=638fd84b-3589-ec11-93b0-0022486dc261; cat_data=[{"EnvironmentUrl":"[https://......crm3.dynamics.com/"}];](https://......crm3.dynamics.com/%22%7D];) cat_usersettingid_Property=[cat_usersettingid, 638fd84b-3589-ec11-93b0-0022486dc261]} variableConfigurationJson: [{"EnvironmentUrl":"[https://.........crm3.dynamics.com/"}](https://.....crm.dynamics.com/%22%7D)] variable: @{EnvironmentUrl=[https://......crm.dynamics.com/}](https://......crm.dynamics.com/%7D) newEnvironmentConfig: @{original=System.Collections.Generic.Dictionary2[System.String,System.Object]; logicalname=cat_usersetting; cat_usersettingid=0bc17b58-3589-ec11-93b0-0022486dcbc8; ReturnProperty_EntityName=cat_usersetting; EntityReference=Microsoft.Xrm.Sdk.EntityReference; cat_data_Property=cat_data, [{"EnvironmentUrl":"[https://.......crm3.dynamics.com/"}]]; ReturnProperty_Id=0bc17b58-3589-ec11-93b0-0022486dcbc8; cat_data={"EnvironmentUrl":"[https://........crm3.dynamics.com/"}]; cat_usersettingid_Property=[cat_usersettingid, 0bc17b58-3589-ec11-93b0-0022486dcbc8]} variableConfigurationJson: [{"EnvironmentUrl":"https://........crm3.dynamics.com/"}] variable: @{EnvironmentUrl=https://..........crm3.dynamics.com/} configurationVariable: #{team.samplegroupteamname.role}# buildVariable: int Length {get;} found: False newEnvironmentConfig: @{original=System.Collections.Generic.Dictionary2[System.String,System.Object]; logicalname=cat_usersetting; cat_usersettingid=638fd84b-3589-ec11-93b0-0022486dc261; ReturnProperty_EntityName=cat_usersetting; EntityReference=Microsoft.Xrm.Sdk.EntityReference; cat_data_Property=[cat_data, [{"EnvironmentUrl":"[https://.......crm3.dynamics.com/"}]];](https://......crm3.dynamics.com/%22%7D]];) ReturnProperty_Id=638fd84b-3589-ec11-93b0-0022486dc261; cat_data=[{"EnvironmentUrl":"[https://.........crm3.dynamics.com/"}];](https://........crm3.dynamics.com/%22%7D];) cat_usersettingid_Property=[cat_usersettingid, 638fd84b-3589-ec11-93b0-0022486dc261]} variableConfigurationJson: [{"EnvironmentUrl":"[https://......crm.dynamics.com/"}](https://.....crm.dynamics.com/%22%7D)] variable: @{EnvironmentUrl=[https://......crm.dynamics.com/}](https://.....crm.dynamics.com/%7D) newEnvironmentConfig: @{original=System.Collections.Generic.Dictionary2[System.String,System.Object]; logicalname=cat_usersetting; cat_usersettingid=0bc17b58-3589-ec11-93b0-0022486dcbc8; ReturnProperty_EntityName=cat_usersetting; EntityReference=Microsoft.Xrm.Sdk.EntityReference; cat_data_Property=cat_data, [{"EnvironmentUrl":"[https://........crm3.dynamics.com/"}]]; ReturnProperty_Id=0bc17b58-3589-ec11-93b0-0022486dcbc8; cat_data={"EnvironmentUrl":"[https://.....crm3.dynamics.com/"}]; cat_usersettingid_Property=[cat_usersettingid, 0bc17b58-3589-ec11-93b0-0022486dcbc8]} variableConfigurationJson: [{"EnvironmentUrl":"https://......crm3.dynamics.com/"}] variable: @{EnvironmentUrl=https://.....crm.dynamics.com/} Exception setting "variables": "The property 'variables' cannot be found on this object. Verify that the property exists and can be set." At D:\a_temp\f32f4f98-68b6-4add-b93d-027b364ec0c7.ps1:324 char:9

[error]PowerShell exited with code '1'.

Finishing: Update Deployment Settings

Expected Behavior

No response

What component are you experiencing the issue with?

ALM Accelerator Pipelines

What solution version are you using?

Latest from Feb

Steps To Reproduce

  1. run the pipeline
  2. previous sets succeed
  3. fails on Update Deployment settings

Anything else?

No response

chrisc-ona commented 2 years ago

From reviewing the documentation for Definitions - List for the version of Azure DevOps REST API used in update-deployment-settings.yml, and other versions as well, the variables property expected on the returned BuildDefinitionReference JSON objects does not exist.

chrisc-ona commented 2 years ago

It appears that Definitions - Get does document a variables property on the returned BuildDefinition JSON object, but this property is missing from the response actually coming from Azure DevOps' REST API.

ChrisL66 commented 2 years ago

I may have been masking the underlying issue trying to get it to work, if I revert the script, I get

added 849 packages, and audited 850 packages in 1m

99 packages are looking for funding run npm fund for details

found 0 vulnerabilities

coe@0.0.1 build tsc

added 1 package, and audited 3 packages in 714ms

found 0 vulnerabilities info: Branch start info: Setup branch info: Using supplied access token Add-Member : Cannot bind argument to parameter 'InputObject' because it is null. At D:\a_temp\84d0a947-5a0c-4416-b8d0-a949fa215643.ps1:277 char:48

Whick I believe is elated to

If the variable was not found create it

            if(!$found) {
                $newBuildDefinitionVariables | Add-Member -MemberType NoteProperty -Name $configurationVariable -Value @{value = ''}
            }
ChrisL66 commented 2 years ago

which seems to tie to echo "buildDefinitionResult.variables: $buildDefinitionResult.variables" <- data is there $newBuildDefinitionVariables = $buildDefinitionResult.variables <- this is failing to set the value? echo "newBuildDefinitionVariables: $newBuildDefinitionVariables"

result: buildDefinitionResult.variables: @{options=System.Object[]; triggers=System.Object[]; properties=; tags=System.Object[]; _links=; jobAuthorizationScope=projectCollection; jobTimeoutInMinutes=60; jobCancelTimeoutInMinutes=5; process=; repository=; quality=definition; authoredBy=; drafts=System.Object[]; queue=; id=33; name=deploy-validation-ALM_test; url=https://aaa.visualstudio.com/d9284fd4-545e-4688-8a0e-3220e313006e/_apis/build/Definitions/33?revision=6; uri=vstfs:///Build/Definition/33; path=\; type=build; queueStatus=enabled; revision=6; createdDate=2022-02-09T12:59:43.187Z; project=}.variables newBuildDefinitionVariables:

ChrisL66 commented 2 years ago

Issue appears we needed to manually create at least variable in the pipeline to get it to be returned via the API call