microsoft / powerplatform-build-tools

Power Platform Build Tools automate common build and deployment tasks related to Power Platform. This includes synchronization of solution metadata (a.k.a. solutions) between development environments and source control, generating build artifacts, deploying to downstream environments, provisioning/de-provisioning of environments, and the ability to perform static analysis checks against your solution using the PowerApps checker service.
MIT License
186 stars 38 forks source link

Importing solution with deployment settings file does not update environment variable #689

Closed jrossstocholm closed 7 months ago

jrossstocholm commented 9 months ago

We have a model-driven Power App that we move from DEV/TEST to STAGING to PROD using Azure pipelines.

The solution is exported as "managed" and this managed solution is then deployed to STAGING subsequently to PROD.

We have a single environment variable that needs to be updated when importing to STAGING/PROD. We have created a deployment settings file with this content:

{
    "EnvironmentVariables": [
      {
        "SchemaName": "gp_WebAPIURI",
        "Value": "https://org0_staging.api.crm4.dynamics.com"
      }
    ]
  }

We have configured the "Solution Import" task like this:

- task: PowerPlatformImportSolution@2
  inputs:
    authenticationType: 'PowerPlatformSPN'
    PowerPlatformSPN: 'app STAGING'
    SolutionInputFile: 'D:\a\1\s\solution_managed.zip'
    #SolutionInputFile: '$(Pipeline.Workspace)/app_managed/solution_managed.zip'
    AsyncOperation: false
    ConvertToManaged: false
    UseDeploymentSettingsFile: true
    DeploymentSettingsFile: 'D:/A/1/app_managed/s/pipelines/deployment-settings_staging.json'
- task: PowerPlatformPublishCustomizations@2
  inputs:
    authenticationType: 'PowerPlatformSPN'
    PowerPlatformSPN: 'app STAGING'
    #Environment: '$(BuildTools.EnvironmentUrl)'
    AsyncOperation: true
    MaxAsyncWaitTime: '60'

The Import task is finished successfully and we can see in the logs that the deployment settings file is loaded

##[debug]UseDeploymentSettingsFile=true
##[debug]DeploymentSettingsFile=D:\A\1\app_managed\s\pipelines\deployment-settings_staging.json

'Calling pac cli inputs: solution import --path D:\\a\\1\\s\\app_managed.zip --async false --force-overwrite false --publish-changes false --skip-dependency-check false --convert-to-managed false --max-async-wait-time 60 --activate-plugins true --skip-lower-version false --settings-file D:\\A\\1\\app_managed\\s\\pipelines\\deployment-settings_staging.json --log-to-console'

[ 'info: bolt.cli.CommandProcessor[0]' ]
[ '      StartExecutingVerb (Verbs: ["solution","import"])' ]
[ 'info: bolt.cli.Verb[0]' ]

[
  "      Executing verb 'solution import' with arguments --path,--async,--force-overwrite,--publish-changes,--skip-dependency-check,--convert-to-managed,--max-async-wait-time,--activate-plugins,--skip-lower-version,--settings-file."
]

But nothing happens - the environment variable is not updated with the new value.

I am kind of at a loss here - I cannot figure out why it is not updated as per the configuration.

What am I doing wrong here?

Thanks 😊

parvezghumra commented 8 months ago

@jrossstocholm Can you try setting the OverwriteUnmanagedCustomizations parameter to true on your solution import task. I'm guessing you have an unmanaged layer on your Environment Variable component

jrossstocholm commented 7 months ago

@jrossstocholm Can you try setting the OverwriteUnmanagedCustomizations parameter to true on your solution import task. I'm guessing you have an unmanaged layer on your Environment Variable component

I do not have any unmanaged layers on my environment variables. However - I have have been able to fix the issue by clearing the environment variable before exporting the solution. This enables me to supply the correct value for my staging environment. I know that this is not a permanent fix - but it works for now 😊.

I will close this ticket now and revert to it when I have time to look into the real issue again.

Thank you.