HodorNV / ALOps

ALOps
59 stars 24 forks source link

Improve Parameter Handling ALOpsAppValidation #606

Closed pri-kise closed 11 months ago

pri-kise commented 1 year ago

Is your feature request related to a problem? Please describe. When I forget to specify a license_path for the Task ALOpsAppValidation I receiv a very cryptic error.

*** Setup Flf File: C:\agent\_work\497\s
*** Flf File: C:\agent\_work\497\s
*** Flf Content:
##[error]Der Zugriff auf den Pfad "C:\agent\_work\497\s" wurde verweigert.

Describe the solution you'd like Provide better check of the parameters instead of using an empty path.

waldo1001 commented 1 year ago

We skip this part when the parameter is null or empty - so I assume it's not null or empty? 🤔

Like a " " (space) or something?

Could you share your yaml?

pri-kise commented 1 year ago

I haven't specified any value for this property. I know it shows the value C:\agent\_work\497\s for this parameter, but in my yaml file I didn't specify any value.

Maybe some other ALOps Task specifies a default value for this property...?

I'm using a CI pipeline that makes use of an template file.

waldo1001 commented 1 year ago

Hm, it doesn't. Could you show the yaml and output (raw)?

waldo1001 commented 1 year ago

@pri-kise , could you share a yaml or raw output?

pri-kise commented 1 year ago
2023-01-31T06:28:59.6308539Z ##[section]Starting: ALOps App Validation
2023-01-31T06:28:59.6450587Z ==============================================================================
2023-01-31T06:28:59.6450979Z Task         : ALOps App Validation
2023-01-31T06:28:59.6451294Z Description  : Validate App from Business Central AppSource
2023-01-31T06:28:59.6451584Z Version      : 1.454.3402
2023-01-31T06:28:59.6451799Z Author       : Hodor
2023-01-31T06:28:59.6452068Z Help         : Validate App from Business Central AppSource.
2023-01-31T06:28:59.6452443Z ==============================================================================
2023-01-31T06:29:01.3077523Z *** Validate configuration
2023-01-31T06:29:01.7446286Z *** Task Inputs:
2023-01-31T06:29:01.7473571Z 
2023-01-31T06:29:01.7593941Z name                value                                                                                              
2023-01-31T06:29:01.7595228Z ----                -----                                                                                              
2023-01-31T06:29:01.7596366Z license_path        C:\agent\_work\497\s                                                                               
2023-01-31T06:29:01.7597128Z countries                                                                                                              
2023-01-31T06:29:01.7597865Z affixes             XXX                                                                                             
2023-01-31T06:29:01.7598478Z artifact_path       C:\agent\_work\497\a\prisma informatik GmbH_Dynamics to DocuWare_1.0.24590.0_sandbox_21.2_de.app   
2023-01-31T06:29:01.7599387Z artifact_filter     *.app                                                                                              
2023-01-31T06:29:01.7599896Z installapps_path    C:\agent\_work\497\a/libraryApps                                                                   
2023-01-31T06:29:01.7600747Z installapps_filter  *.app                                                                                              
2023-01-31T06:29:01.7601297Z previousapps_path   C:\agent\_work\497\apreviousApps                                                                   
2023-01-31T06:29:01.7602398Z previousapps_filter *.app                                                                                              
2023-01-31T06:29:01.7602819Z memory              8G                                                                                                 
2023-01-31T06:29:01.7603547Z validateversion     ?.?.*.0                                                                                            
2023-01-31T06:29:01.7604004Z validatecurrent     True                                                                                               
2023-01-31T06:29:01.7604869Z validatenextminor   True                                                                                               
2023-01-31T06:29:01.7605332Z validatenextmajor   False                                                                                              
2023-01-31T06:29:01.7646885Z sastoken            XXX
2023-01-31T06:29:01.7647580Z skipverification    False                                                                                              
2023-01-31T06:29:01.7648189Z skipappsourcecop    False                                                                                              
2023-01-31T06:29:01.7648983Z includewarnings     True                                                                                               
2023-01-31T06:29:01.7649618Z failonerror         False                                                                                              
2023-01-31T06:29:01.7650162Z containername       bcserver                                                                                           
2023-01-31T06:29:01.7650460Z 
2023-01-31T06:29:01.7672744Z 
2023-01-31T06:29:01.7682363Z 
2023-01-31T06:29:01.7870955Z *** For documentation, please visit   : https://www.alops.be/documentation
2023-01-31T06:29:01.7947353Z 
2023-01-31T06:29:02.1782445Z *** ALOps License:
2023-01-31T06:29:02.1810594Z   * Licensed To: prisma informatik GmbH (Organisation License)
2023-01-31T06:29:02.1815249Z 
2023-01-31T06:29:02.2249353Z *** Importing required PS-Functions
2023-01-31T06:29:02.2944789Z *** Install/Update BCContainerHelper [https://github.com/microsoft/navcontainerhelper]
2023-01-31T06:29:02.2999759Z *** Check BcContainerHelper
2023-01-31T06:29:02.3884804Z *** Load BcContainerHelper
2023-01-31T06:29:02.4510378Z BcContainerHelper version 4.0.2
2023-01-31T06:29:02.5759759Z BcContainerHelper emits usage statistics telemetry to Microsoft
2023-01-31T06:29:03.6891461Z 
2023-01-31T06:29:03.6892509Z ModuleType Version    Name                                ExportedCommands                                             
2023-01-31T06:29:03.6893028Z ---------- -------    ----                                ----------------                                             
2023-01-31T06:29:03.6893957Z Script     4.0.2      BcContainerHelper                   {Add-FontsToBcContainer, Add-GitToAlProjectFolder, Backup-...
2023-01-31T06:29:03.6894394Z 
2023-01-31T06:29:03.6894603Z 
2023-01-31T06:29:03.6894802Z 
2023-01-31T06:29:03.6896779Z 
2023-01-31T06:29:03.6908376Z *** Setup Flf File: C:\agent\_work\497\s
2023-01-31T06:29:03.6969081Z *** Flf File: C:\agent\_work\497\s
2023-01-31T06:29:03.6979148Z *** Flf Content:
2023-01-31T06:29:04.0088136Z ##[error]Der Zugriff auf den Pfad "C:\agent\_work\497\s" wurde verweigert.
2023-01-31T06:29:04.0457661Z ##[section]Finishing: ALOps App Validation
pri-kise commented 1 year ago

Here my template file

parameters:
  selectVersions: ['Current']
  countries: ['de']
  skipverification: false
  alsourcepath: ''
  appversiontemplate: ''
  pool: ''
  codeSigningPasscode: ''
  sasToken: ''

stages:
- ${{ each country in parameters.countries }}:
  - stage: 'build_${{ country }}'
    displayName: 'Build for ${{ country }}'
    dependsOn: [] #run indepedently
    jobs:
    - job: 'build_${{ country }}'
      displayName: 'Job - Validate  ${{ country }}'
      pool:
        name: ${{ parameters.pool }}
      workspace:
        clean: all # what to clean up before the job runs - outputs | resources | all
      steps:

      # Details: https://github.com/microsoft/navcontainerhelper/issues/2474
      - task: PowerShell@2
        displayName: 'Determines the second most recent BC version'
        inputs:
          targetType: 'filePath'
          filePath: './.azuredevops/SetSecondLatestSandboxVersion.ps1'
          arguments: > # Use this to avoid newline characters in multiline string
            -country "${{ country }}"

      - task: ALOpsDockerCreate@1
        displayName: 'ALOps Docker Create'
        inputs:
          artifactversion: '$(ArtifactVersion)'
          artifacttype: 'Sandbox'
          artifactcountry: '${{ country }}'
          licensefile: '\\files\DevOps\Common\prisma_BC.flf'

      - task: ALOpsDockerStart@1
        displayName: 'ALOps Docker Start'
        inputs:
          memory_gb: '8'

      - task: ALOpsDockerWait@1
        displayName: 'ALOps Docker Wait'
        inputs:
          search_string: 'Ready for connections!'

      - task: DownloadBuildArtifacts@0
        displayName: 'Download LicenseModule'
        inputs:
          buildType: 'specific'
          project: '00000000-0000-0000-0000-000000000000'
          pipeline: '532'
          buildVersionToDownload: 'latestFromBranch'
          allowPartiallySucceededBuilds: true
          branchName: 'refs/heads/main'
          downloadType: 'specific'
          itemPattern: '**/*.app'
          downloadPath: '$(System.ArtifactsDirectory)'

      - task: ALOpsAppPublish@1
        displayName: 'Publish LicenseModule'
        inputs:
          usedocker: true
          nav_artifact_app_filter: '*.app'

      - task: DownloadBuildArtifacts@0
        displayName: 'Download Previous Version'
        continueOnError: true
        inputs:
          buildType: 'specific'
          project: '$(System.TeamProjectId)'
          pipeline: 502
          buildVersionToDownload: 'latestFromBranch'
          allowPartiallySucceededBuilds: true
          branchName: 'refs/heads/main'
          downloadType: 'specific'
          itemPattern: '**/*.app'
          downloadPath: '$(System.ArtifactsDirectory)'

      - task: ALOpsAppPublish@1
        displayName: 'Publish Previous Version'
        condition: in(variables['Agent.JobStatus'], 'Succeeded')
        inputs:
          usedocker: true
          nav_artifact_app_filter: '*.app'

      - task: ALOpsAppCompiler@1
        displayName: 'ALOps App Compiler'
        inputs:
          usedocker: true
          targetproject: 'MainApp/app.json'
          al_analyzer: 'AppSourceCop,CodeCop,UICop'
          nav_app_version: '$(AppVersion)'
          publish_artifact: false

      - task: ALOpsAppPublish@1
        displayName: 'ALOps App Publish'
        inputs:
          usedocker: true
          nav_artifact_app_filter: '*.app'

      #Xliff Check
      - task: ALOpsAppCompiler@2
        displayName: 'ALOps App Compiler v2 for Xliff Check'
        inputs:
          artifacttype: 'Sandbox'
          artifactcountry: '${{ country }}'
          artifactversion: '$(ArtifactVersion)'
          alsourcepath: '$(System.DefaultWorkingDirectory)/MainApp'
          appversiontemplate: '$(AppVersion)'
          alcodeanalyzer: 'AppSourceCop,CodeCop,UICop'
          publishartifact: false

      - task: CmdLine@2
        displayName: "Check Xliff Files"
        inputs:
          script: '"\\files\DevOps\Common\XliffCheckV2\App.exe" $(Build.SourcesDirectory)\MainApp\Translations\'

      #TestApp
      - task: ALOpsAppPublish@1
        displayName: 'ALOps Install AL TestTool'
        inputs:
          usedocker: true
          installaltesttool: true
          install_al_app_names: |
            System Application Test Library
            Library Variable Storage
            Permissions Mock
            Library Assert
            Any
            Test Runner
            Tests-TestLibraries
          strictappnames: true

      - task: ALOpsAppCompiler@1
        displayName: 'ALOps Compile Test-App'
        inputs:
          usedocker: true
          targetproject: 'TestApp/app.json'
          nav_app_version: '$(AppVersion)'
          publish_artifact: false
          failed_on_warnings: true

      - task: ALOpsAppPublish@1
        displayName: 'ALOps Publish Test-App'
        inputs:
          usedocker: true
          nav_artifact_app_filter: '*.app'

      - task: ALOpsAppTest@1
        displayName: 'ALOps Run TestSuite'
        inputs:
          usedocker: true
          import_testtoolkit: false
          import_action: 'Skip'
          testpage: '130455'
          installaltesttool: true
        continueOnError: true

      - task: PublishTestResults@2
        displayName: 'Publish Test Results'
        inputs:
          testResultsFormat: 'XUnit'
          testResultsFiles: '**/TestResults.xml'
          testRunTitle: 'BC Test Results: $(Build.BuildId)'

      - task: ALOpsDockerRemove@1
        displayName: 'ALOps App Remove'
        enabled: true
        condition: always()

# Run AL Validation Stage only once
- stage: 'RunALValidation'
  displayName: 'Run AL Validation'
  dependsOn: [] #run indepedently
  jobs:
  - job: 'RunALValidationJob'
    displayName: 'Job - Validate'
    pool:
      name: ${{ parameters.pool }}
    workspace:
      clean: all # what to clean up before the job runs - outputs | resources | all
    steps:

    # Details: https://github.com/microsoft/navcontainerhelper/issues/2474
    - task: PowerShell@2
      displayName: 'Determines the second most recent BC version'
      inputs:
        targetType: 'filePath'
        filePath: './.azuredevops/SetSecondLatestSandboxVersion.ps1'
        arguments: > # Use this to avoid newline characters in multiline string
          -country "$(ArtifactCountry)"

    - task: DownloadBuildArtifacts@0
      displayName: 'Download PRI-BC-LicenseModule'
      inputs:
        buildType: 'specific'
        project: 'cbc3ff6e-47a8-44ac-b2b3-7cbdbf20e97a'
        pipeline: '532'
        buildVersionToDownload: 'latestFromBranch'
        allowPartiallySucceededBuilds: true
        branchName: 'refs/heads/main'
        downloadType: 'specific'
        itemPattern: '**/*.app'
        downloadPath: '$(System.ArtifactsDirectory)/libraryApps'

    - task: DownloadBuildArtifacts@0
      displayName: 'Download Previous Version'
      continueOnError: true
      inputs:
        buildType: 'specific'
        project: '$(System.TeamProjectId)'
        pipeline: 502
        buildVersionToDownload: 'latestFromBranch'
        allowPartiallySucceededBuilds: true
        branchName: 'refs/heads/main'
        downloadType: 'specific'
        itemPattern: '**/*.app'
        downloadPath: '$(System.ArtifactsDirectory)/previousApps'

    - task: ALOpsAppCompiler@2
      displayName: 'ALOps App Compiler'
      inputs:
        artifacttype: 'Sandbox'
        artifactcountry: '$(ArtifactCountry)'
        artifactversion: '$(ArtifactVersion)'
        publishartifact: false
        alsourcepath: '$(System.DefaultWorkingDirectory)/MainApp'
        appversiontemplate: '$(AppVersion)'
        alcodeanalyzer: 'AppSourceCop,CodeCop,UICop'

    - task: ALOpsAppSign@1
      displayName: 'ALOps App Sign'
      inputs:
        usedocker: false
        publishartifact: false
        artifact_path: $(ALOPS_COMPILE_ARTIFACT)
        pfx_path: '\\files\DevOps\Common\CodeSigning\CodeSigning.pfx'
        pfx_password: ${{parameters.codeSigningPasscode}}

    - task: ALOpsAppValidation@1
      displayName: 'ALOps App Validation'
      inputs:
        affixes: 'PRI_DW'
        artifact_path: $(ALOPS_COMPILE_ARTIFACT)
        installapps_path: '$(System.ArtifactsDirectory)/libraryApps' # Path for InstallApps Artifact(s). $(installapps_path)
        previousapps_path: '$(System.ArtifactsDirectory)previousApps' # Path for PreviousApps Artifact(s). $(previousapps_path)
        validateversion: '$(AppVersion)'      # Full or partial version number. If specified, apps will also be validated against this version. $(validateversion)
        validatecurrent: True                # Validate against current version of Business Central. $(validatecurrent)
        validatenextminor: True              # Validate against Next Minor version of Business Central. $(validatenextminor)
        validatenextmajor: False              # Validate against Next Major version of Business Central. $(validatenextmajor)
        sastoken:  ${{parameters.sasToken}} # SAS Token used to access Storage Account. $(sastoken)
        includewarnings: True                # Include this switch if you want to include Warnings. $(includewarnings)
        failonerror: False                     # Include this switch if you want to fail on the first error instead of returning all errors to the caller. $(failonerror)
pri-kise commented 1 year ago

Here is my template file and my output. I only removed the sastoken and replaced one guid with a empty guid.

waldo1001 commented 1 year ago

Can you try the following:

add a new step "AlopsAppinfo@1" before the "ALOpsAppValidation" step, to see which variables you have at that moment. You can mail the output to admin@hodor.be .

Thanks in advance!

waldo1001 commented 1 year ago

To investigate this problem more, we added some more output on this task, to decently see what might be the problem with your parameters.

waldo1001 commented 1 year ago

@pri-kise ,

The additional logging should already be online for a while. Were you able to resolve the issue, or can you send us (admin@hodor.be) a detailed log again so we can look into it again?

waldo1001 commented 11 months ago

@pri-kise ?

Can you also re-validate this issue, since there have been a number of updates since here.