Skip to content

ALOps Agent Maintenance

Cleanup and maintenance for DevOps agents running Business Central workloads. Supports Docker, BC Artifacts, package and temp caches, and old task cleanup with dry-run mode and disk metrics.

Property Value
Task name (Azure DevOps) ALOpsAgentMaintenance@3
Action name (GitHub) alops-agentmaintenance
Version 3.0.0
Category Utility
OS requirement Both
Preview yes

Cleans up Docker resources (containers, images, volumes, build cache), BC Artifact caches, agent/Windows temp folders, package caches, and old ALOps task versions. Supports dry-run mode for previewing cleanup actions. Reports disk space freed and sets pipeline output variables for downstream steps.

Inputs

docker

Name Type Required Default Platform Description
docker_containers Boolean no false Both Remove all stopped/exited Docker containers (docker container prune).
docker_images Boolean no false Both Remove Docker images older than the specified number of days.
prune_images_days_created Text no 0 Both Remove Docker images older than this many days. Set to 0 to skip age-based image pruning. (Only applies when 'Prune Docker Images by Age' is enabled.)
docker_images_by_os Boolean no false Both Remove Docker images whose OS version does not match the host OS. Uses direct Docker inspect (no BcContainerHelper dependency). Primarily relevant for Windows containers.
docker_volumes Boolean no false Both Remove all dangling (unused) Docker volumes.
docker_build_cache Boolean no false Both Remove all Docker build cache (docker builder prune).

artifacts

Name Type Required Default Platform Description
bc_artifacts Boolean no false Both Remove unused BC Artifact cache folders, orphaned VSIX extractions, temp folders, and empty directories.
bc_artifacts_cache_folder Text no (empty) Both Path to the BC Artifacts cache folder. Leave empty for auto-detection (checks bcaboragentartifactspath env var, then falls back to a platform default). (Only applies when 'Clean BC Artifacts Cache' is enabled.)
package_cache Boolean no false Both Remove old ALTool/compiler packages from the agent tools directory and old NuGet global cache packages.

agent

Name Type Required Default Platform Description
old_tasks Boolean no false Both Remove old ALOps task version folders from the agent. Auto-detects the current version and removes all older versions. (Azure DevOps agents only.)
agent_temp Boolean no false Both Remove old files and folders from the agent temp directory (AGENT_TEMPDIRECTORY / RUNNER_TEMP).
windows_temp Boolean no false Both Remove old files and folders from the Windows temp directory (TEMP). Windows agents only; no-ops on other platforms.

advanced

Name Type Required Default Platform Description
days_unused Text no 30 Both Threshold in days for cleanup operations. Items not used within this period are removed. Applies to BC Artifacts, Agent Temp, Windows Temp, and Package Cache operations.
dry_run Boolean no false Both When enabled, reports what would be cleaned without actually deleting anything. Use this for change-management review before running actual cleanup.
failure_action PickList no Warn Both How cleanup failures affect the task result. 'Error' fails the task on any cleanup error. 'Warn' logs warnings (SucceededWithIssues). 'Ignore' silently continues. Options: Error, Warn, Ignore.

Outputs

Name Description
freed_bytes Total bytes freed across all operations.
freed_mb Total megabytes freed across all operations.
images_removed Number of Docker images removed.
containers_removed Number of Docker containers removed.
artifacts_removed Number of BC artifact cache items removed.
operations_failed Number of cleanup operations that reported errors.
dry_run Whether the task ran in dry-run mode (no deletions).

Usage

- task: ALOpsAgentMaintenance@3
  displayName: 'ALOps Agent Maintenance'
  inputs:
    docker_containers: False              # Remove all stopped/exited Docker containers (docker container prune). $(docker_containers)
    docker_images: False                  # Remove Docker images older than the specified number of days. $(docker_images)
    prune_images_days_created: 0          # Remove Docker images older than this many days. Set to 0 to skip age-based image pruning. (Only applies when 'Prune Docker Images by Age' is enabled.) $(prune_images_days_created)
    docker_images_by_os: False            # Remove Docker images whose OS version does not match the host OS. Uses direct Docker inspect (no BcContainerHelper dependency). Primarily relevant for Windows containers. $(docker_images_by_os)
    docker_volumes: False                 # Remove all dangling (unused) Docker volumes. $(docker_volumes)
    docker_build_cache: False             # Remove all Docker build cache (docker builder prune). $(docker_build_cache)
    bc_artifacts: False                   # Remove unused BC Artifact cache folders, orphaned VSIX extractions, temp folders, and empty directories. $(bc_artifacts)
    bc_artifacts_cache_folder:            # Path to the BC Artifacts cache folder. Leave empty for auto-detection (checks bcaboragentartifactspath env var, then falls back to a platform default). (Only applies when 'Clean BC Artifacts Cache' is enabled.) $(bc_artifacts_cache_folder)
    package_cache: False                  # Remove old ALTool/compiler packages from the agent tools directory and old NuGet global cache packages. $(package_cache)
    old_tasks: False                      # Remove old ALOps task version folders from the agent. Auto-detects the current version and removes all older versions. (Azure DevOps agents only.) $(old_tasks)
    agent_temp: False                     # Remove old files and folders from the agent temp directory (AGENT_TEMPDIRECTORY / RUNNER_TEMP). $(agent_temp)
    windows_temp: False                   # Remove old files and folders from the Windows temp directory (TEMP). Windows agents only; no-ops on other platforms. $(windows_temp)
    days_unused: 30                       # Threshold in days for cleanup operations. Items not used within this period are removed. Applies to BC Artifacts, Agent Temp, Windows Temp, and Package Cache operations. $(days_unused)
    dry_run: False                        # When enabled, reports what would be cleaned without actually deleting anything. Use this for change-management review before running actual cleanup. $(dry_run)
    failure_action: Warn                  # How cleanup failures affect the task result. 'Error' fails the task on any cleanup error. 'Warn' logs warnings (SucceededWithIssues). 'Ignore' silently continues. $(failure_action)
- name: ALOps Agent Maintenance
  uses: HodorNV/ALOps/Actions/alops-agentmaintenance@master
  with:
    docker_containers: 'false'
    docker_images: 'false'
    prune_images_days_created: '0'
    docker_images_by_os: 'false'
    docker_volumes: 'false'
    docker_build_cache: 'false'
    bc_artifacts: 'false'
    bc_artifacts_cache_folder: ''
    package_cache: 'false'
    old_tasks: 'false'
    agent_temp: 'false'
    windows_temp: 'false'
    days_unused: '30'
    dry_run: 'false'
    failure_action: 'Warn'