trigger: none
pr:
branches:
include:
- feature/*
pool:
name: 'BCLocalizareExtensii'
variables:
ContainerName: 'BLDAg'
BcUser: 'mihai'
BcPassword: 'mihai'
steps:
# Cache AL symbols
- task: Cache@2
displayName: 'Cache AL symbols (.alpackages)'
inputs:
key: 'alpackages | $(Agent.OS) | $(Build.SourcesDirectory)/app.json'
path: '$(Build.SourcesDirectory)/.alpackages'
restoreKeys: |
alpackages | $(Agent.OS)
alpackages
continueOnError: true
# Install PowerShell modules
- task: PowerShell@2
displayName: 'Install PowerShell modules'
inputs:
targetType: 'inline'
script: |
Set-StrictMode -Off
$ExecutionContext.SessionState.PSVariable.Set('StrictModePreference','Off')
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted -ErrorAction SilentlyContinue
if (-not (Get-Module -ListAvailable -Name 'BcContainerHelper')) {
Install-Module BcContainerHelper -Scope CurrentUser -Force -AllowClobber
} else {
Update-Module BcContainerHelper -Force -ErrorAction SilentlyContinue
}
if (-not (Get-Module -ListAvailable -Name 'BC.HelperFunctions')) {
Install-Module BC.HelperFunctions -Scope CurrentUser -Force -AllowClobber
} else {
Update-Module BC.HelperFunctions -Force -ErrorAction SilentlyContinue
}
$global:bcContainerHelperConfig = [ordered]@{
MicrosoftTelemetryConnectionString = ''
PartnerTelemetryConnectionString = ''
ApplicationInsightsConnectionString = ''
}
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Install-Module BcContainerHelper -Force -AllowClobber
#Import-Module BcContainerHelper -Force
#Import-Module BC.HelperFunctions -Force
#Write-Host "BcContainerHelper version: $((Get-Module BcContainerHelper).Version)"
#Write-Host "BC.HelperFunctions version: $((Get-Module BC.HelperFunctions).Version)"
# Validate existing BC container
- task: PowerShell@2
displayName: 'Validate existing BC container'
inputs:
targetType: 'inline'
script: |
Set-StrictMode -Off
$ExecutionContext.SessionState.PSVariable.Set('StrictModePreference','Off')
$containerName = '$(ContainerName)'
if (docker ps --format "{{.Names}}" | Select-String -SimpleMatch $containerName) {
Write-Host "Container $containerName is running."
} elseif (docker ps -a --format "{{.Names}}" | Select-String -SimpleMatch $containerName) {
Write-Host "Container $containerName exists but is stopped. Starting it..."
docker start $containerName
} else {
throw "Container $containerName does not exist. Please create it manually before running this pipeline."
}
# Download Symbols
- task: PowerShell@2
displayName: 'Download Symbols (from container)'
inputs:
targetType: 'inline'
script: |
Set-StrictMode -Off
$ExecutionContext.SessionState.PSVariable.Set('StrictModePreference','Off')
$global:bcContainerHelperConfig = [ordered]@{
MicrosoftTelemetryConnectionString = ''
PartnerTelemetryConnectionString = ''
ApplicationInsightsConnectionString = ''
}
Import-Module BcContainerHelper -Force
Import-Module BC.HelperFunctions -Force
$projectPath = "$(Build.SourcesDirectory)"
$alCachePath = Join-Path $projectPath ".alpackages"
New-Item -ItemType Directory -Force -Path $alCachePath | Out-Null
$containerName = '$(ContainerName)'
Download-BcAppSymbols `
-containerName $containerName `
-projectPath $projectPath `
-alCachePath $alCachePath
Write-Host "Symbols downloaded to: $alCachePath"
# Compile AL Project
- task: PowerShell@2
displayName: 'Compile AL Project (container)'
inputs:
targetType: 'inline'
script: |
Set-StrictMode -Off
$ExecutionContext.SessionState.PSVariable.Set('StrictModePreference','Off')
$global:bcContainerHelperConfig = [ordered]@{
MicrosoftTelemetryConnectionString = ''
PartnerTelemetryConnectionString = ''
ApplicationInsightsConnectionString = ''
}
Import-Module BcContainerHelper -Force
Import-Module BC.HelperFunctions -Force
$projectPath = "$(Build.SourcesDirectory)"
$containerName = '$(ContainerName)'
$ruleset = Join-Path $projectPath "ruleset.json"
$rulesetParam = @()
if (Test-Path $ruleset) { $rulesetParam = @('-rulesetFile', $ruleset) }
Compile-App `
-containerName $containerName `
-projectPath $projectPath `
@rulesetParam `
-enableCodeCop `
-enableAppSourceCop `
-enablePerTenantExtensionCop `
-enableUICop
# Analyze Breaking Changes
- task: PowerShell@2
displayName: 'Analyze Breaking Changes'
inputs:
targetType: 'inline'
script: |
Set-StrictMode -Off
$ExecutionContext.SessionState.PSVariable.Set('StrictModePreference','Off')
Import-Module BC.HelperFunctions -Force
$previousApp = "$(Build.SourcesDirectory)\PreviousVersion.app"
if (Test-Path $previousApp) {
Analyze-AppSourceCop `
-previousApp $previousApp `
-currentApp "$(Build.SourcesDirectory)\app.json"
} else {
Write-Host "No previous app found, skipping breaking change analysis."
}
# Publish .app artifact
- task: PublishBuildArtifacts@1
displayName: 'Publish .app artifact'
inputs:
pathtoPublish: '$(Build.SourcesDirectory)'
artifactName: 'AL-Output'
publishLocation: 'Container'
# Cleanup container (optional)
- task: PowerShell@2
displayName: 'Leave container running'
condition: always()
inputs:
targetType: 'inline'
script: |
Write-Host "Container $(ContainerName) will remain running."