Personal note on how to implement a basic CI/CD Pipeline for automated building of Keil uVision projects using Gitlab CI/CD.
I will update the post time permitting.

Keil uVision Command Line reference


build_debug:
    stage: build
    tags:
        - windows
    variables:
        GIT_SUBMODULE_STRATEGY: recursive
    script:
        - C:\Keil_v5\UV4\UV4.exe -crb .\projectname.uvprojx -t"Debug" -o .\Objects\build.log -sg -j0 | Out-Null; $LASTEXITCODE
        - if ( $LASTEXITCODE -eq 0 ) { echo "No Errors or Warnings"; Exit 0 }
          elseif ( $LASTEXITCODE -eq 1 ) { echo "Warnings Only"; Exit 0 }
          elseif ( $LASTEXITCODE -eq 2 ) { echo "Errors"; Exit 2 }
          elseif ( $LASTEXITCODE -eq 3 ) { echo "Fatal Errors"; Exit 3 }
          elseif ( $LASTEXITCODE -eq 11 ) { echo "Cannot open project file for writing"; Exit 11 }
          elseif ( $LASTEXITCODE -eq 12 ) { echo "Device with given name in not found in database"; Exit 12 }
          elseif ( $LASTEXITCODE -eq 13 ) { echo "Error writing project file"; Exit 13 }
          elseif ( $LASTEXITCODE -eq 15 ) { echo "Error reading import XML file"; Exit 15 }
          elseif ( $LASTEXITCODE -eq 20 ) { echo "Error converting project"; Exit 20 }
    after_script:
        - Get-Content -Tail 4 .\Objects\build.log
    artifacts:
        when: always
        paths:
            - Objects\*.hex
            - Objects\*.axf
            - Objects\*.htm
            - Objects\*.log
            - Listings\*.map

build_release:
    stage: build
    tags:
        - windows
    variables:
        GIT_SUBMODULE_STRATEGY: recursive
    script:
        - C:\Keil_v5\UV4\UV4.exe -crb .\projectname.uvprojx -t"Release" -o .\Objects\build.log -sg -j0 | Out-Null; $LASTEXITCODE
        - if ( $LASTEXITCODE -eq 0 ) { echo "No Errors or Warnings"; Exit 0 }
          elseif ( $LASTEXITCODE -eq 1 ) { echo "Warnings Only"; Exit 0 }
          elseif ( $LASTEXITCODE -eq 2 ) { echo "Errors"; Exit 2 }
          elseif ( $LASTEXITCODE -eq 3 ) { echo "Fatal Errors"; Exit 3 }
          elseif ( $LASTEXITCODE -eq 11 ) { echo "Cannot open project file for writing"; Exit 11 }
          elseif ( $LASTEXITCODE -eq 12 ) { echo "Device with given name in not found in database"; Exit 12 }
          elseif ( $LASTEXITCODE -eq 13 ) { echo "Error writing project file"; Exit 13 }
          elseif ( $LASTEXITCODE -eq 15 ) { echo "Error reading import XML file"; Exit 15 }
          elseif ( $LASTEXITCODE -eq 20 ) { echo "Error converting project"; Exit 20 }
    after_script:
        - Get-Content -Tail 4 .\Objects\build.log
    artifacts:
        when: always
        paths:
            - Objects\*.hex
            - Objects\*.axf
            - Objects\*.htm
            - Objects\*.log
            - Listings\*.map