almenscorner/IntuneCD

[BUG] - Markdown generation failing on Hebrew characters

Closed this issue · 1 comments

Describe the bug
Failure in Azure Pipeline during markdown document generation stage.

##[error]/home/vsts/work/_temp/03a466b9-ec4f-42a0-a14a-f3fefac2cfc5.sh: line 1: [: prod-backup/Applications/Android/HILANET: binary operator expected

To Reproduce
Add Hilanet application to Google Play store and assign it to users.
https://play.google.com/store/apps/details?id=il.co.hilanet.HilanetMobile&hl=en&gl=US

Expected behavior
Markdown documentation generated correctly for the applications listed.

Screenshots
image

Run type (please complete the following information):

  • Mode: [e.g. 0 or 1] - 1
  • Client [e.g. Pipeline, local machine] - Pipeline
  • Version [e.g. 1.0.2] - 2.0.7

Additional context

Pipeline details

`# Starter pipeline

Start with a minimal pipeline that you can customize to build and deploy your code.

Add steps that build, run tests, deploy, and more:

https://aka.ms/yaml

trigger:
none
schedules:

  • cron: '0 22 * * *'
    displayName: "10PM Everyday"
    branches:
    include:
    • main
      always: true

pool:
vmImage: ubuntu-latest

jobs:

  • job: backup_document
    displayName: Backup Intune configuration
    pool:
    vmImage: ubuntu-latest
    continueOnError: false
    steps:

    • checkout: self
      persistCredentials: true

    Set git global settings

    • task: Bash@3
      displayName: Configure Git Global Settings
      inputs:
      targetType: 'inline'
      script: |
      git config --global user.name $(USER_NAME)
      git config --global user.email $(USER_EMAIL)
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: true
    • task: Bash@3
      displayName: Remove existing prod-backup directory
      inputs:
      targetType: 'inline'
      script: |
      rm -rfv "$(Build.SourcesDirectory)/prod-backup"
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: false

    Install IntuneCD

    https://github.com/almenscorner/IntuneCD

    • task: Bash@3
      displayName: Install IntuneCD Package V2.0.7
      inputs:
      targetType: 'inline'
      script: |
      pip3 install IntuneCD==2.0.7
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: true

    Backup the latest configuration, using the current directory

    • task: Bash@3
      displayName: IntuneCD backup Start
      inputs:
      targetType: 'inline'
      script: |
      mkdir -p "$(Build.SourcesDirectory)/prod-backup"
      IntuneCD-startbackup
      --mode=1
      --path "$(Build.SourcesDirectory)/prod-backup"
      --exclude ConditionalAccess
      --ignore-omasettings
      --append-id
      --autopilot=True
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: true
      env:
      TENANT_NAME: $(TENANT_NAME)
      CLIENT_ID: $(CLIENT_ID)
      CLIENT_SECRET: $(CLIENT_SECRET)

    Commit changes and push to Azure DevOps repo

    • task: Bash@3
      displayName: Commit changes to Azure DevOps repo
      name: commitAndsetVariable
      inputs:
      targetType: 'inline'
      script: |
      DATEF=date +%Y.%m.%d
      git add --all
      # modified files in folder prod-backup
      var=$(git diff --name-only --staged -- prod-backup)
      echo "##vso[task.setVariable variable=CHANGE_DETECTED;isOutput=true;]$var"
      git commit -m "Intune config backup $DATEF"
      git push origin HEAD:main
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: false

    Create markdown documentation

    Install IntuneCD

    https://github.com/almenscorner/IntuneCD

    • task: Bash@3
      displayName: Generate markdown document
      inputs:
      targetType: 'inline'
      script: |
      if [ ! -z "$(commitAndsetVariable.CHANGE_DETECTED)" ]
      then
      INTRO="Intune backup and documentation generated at $(Build.Repository.Uri) <img align="right" width="96" height="96" src="./logo.png">"
      IntuneCD-startdocumentation
      --path="$(Build.SourcesDirectory)/prod-backup"
      --outpath="$(Build.SourcesDirectory)/prod-as-built.md"
      --tenantname=$TENANT_NAME
      --intro="$INTRO"
      #--split=Y
      else
      echo "no configuration backup change detected in the last commit, documentation will not be created"
      fi
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: true
      env:
      TENANT_NAME: $(TENANT_NAME)

    Commit changes and push to repo

    • task: Bash@3
      displayName: Commit changes
      inputs:
      targetType: 'inline'
      script: |
      DATEF=date +%Y.%m.%d
      git add --all
      git commit -m "Intune config as-built $DATEF"
      git push origin HEAD:main
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: false
  • job: tag
    displayName: Tag repo
    dependsOn: backup_document
    condition: and(succeeded(), ne(dependencies.backup_document.outputs['commitAndsetVariable.CHANGE_DETECTED'], ''))
    pool:
    vmImage: ubuntu-latest
    continueOnError: false
    steps:

    • checkout: self
      persistCredentials: true

    Set git global settings

    • task: Bash@3
      displayName: Configure Git
      inputs:
      targetType: 'inline'
      script: |
      git config --global user.name $(USER_NAME)
      git config --global user.email $(USER_EMAIL)
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: true

    • task: Bash@3
      displayName: Pull origin
      inputs:
      targetType: 'inline'
      script: |
      git pull origin main
      workingDirectory: '$(Build.SourcesDirectory)'
      failOnStderr: false

    • task: PowerShell@2
      displayName: Git tag
      inputs:
      targetType: 'inline'
      script: |
      # change in configuration backup folder detected, create TAG
      $DATEF= Get-Date -format "yyyy-MM-dd_THH-mm"
      git tag -a "v$DATEF" -m "Microsoft Intune configuration snapshot $DATEF"
      git push origin "v$DATEF" *> $null # even status information goes to stderr :(
      failOnStderr: true
      pwsh: false
      workingDirectory: '$(Build.SourcesDirectory)'

  • job: publish
    displayName: Publish as-built artifacts
    dependsOn: tag
    condition: and(succeeded(), ne(dependencies.backup_document.outputs['commitAndsetVariable.CHANGE_DETECTED'], ''))
    pool:
    vmImage: ubuntu-latest
    continueOnError: false
    steps:

    • checkout: self
      persistCredentials: true`

Seems to have resolved itself :)