Automatically archive tasks according to a user-defined policy
This topic explains how to manage active tasks using the Monitoring section.
Deploy keeps all active tasks in the Monitoring section, which is located under the search bar at the top left of the screen.
Executed tasks are archived when you manually click Close or Cancel on the task. You can define a custom task archive policy that will automatically archive tasks that are visible in Monitoring.
About Task States
Before configuring a custom task archive policy, ensure that you are familiar with the Deploy task states.
Automatically Archive Active Tasks
To automatically archive active tasks according to a policy:
- From the side bar, click Configuration
- Click
, then select New > Policy >
policy.TaskArchivePolicy. - In the Name field, enter a unique policy name.
- In the Days to retain tasks field, enter the number of days that Deploy should retain tasks. If 0 days is specified, all active tasks are subject to archiving.
- The
TaskyArchivePolicycan only be setup by an administrator user. - By default, successfully-executed active tasks and failed tasks are archived. This can be changed from the Common section by toggling the Include executed tasks and Include failed tasks options.
- A policy will attempt to archive any tasks that are in one of the following passive states:
EXECUTED,STOPPED,FAILED, orABORTED. Specifically, the policy will attempt to:- Complete the
EXECUTEDtasks, transitioning them to theDONEstate. - Cancel any
STOPPED,FAILED, andABORTEDtasks, transitioning them to theCANCELLEDstate.
- Complete the
- Canceling will trigger any
alwaysExecutedphases, so some tasks may re-run as the cleanup phase of a plan is executed in which staged files are removed, and deployeds are registered. - By default, automatic policy execution is enabled and will run according to the crontab schedule defined in the Schedule section. Optionally, you can change the crontab schedule or disable policy execution.
- You can manually execute a task archive policy by right-clicking it and selecting Execute job now. To test the policy by running it without removing tasks: from the Schedule section, select Dry run policy.
Who Can Execute the Archive Policy
The users who can execute the archive policy depend on the authentication method and the worker setup. In a master-worker setup, the worker sends an API request to the master to retrieve the current task details, and the policy is executed based on the response. With OIDC enabled, this request is restricted to the internal administrator user.
For a master-worker setup with an external worker:
| Authentication method | Users who can execute the archive policy |
|---|---|
| OIDC | Only the internal administrator user. |
| LDAP | The internal administrator user, and internal or LDAP users that have the admin permission, or the login, control-task-execute, and read permissions. |
| Default | The internal administrator user, and internal users that have the admin permission, or the login, control-task-execute, and read permissions. |
| OIDC combined with LDAP or default | Only the internal administrator user. |
For an in-process worker setup, OIDC, LDAP, and default authentication behave the same. The internal administrator user, and internal, LDAP, or OIDC users that have the admin permission, or the login, control-task-execute, and read permissions, can execute the archive policy.
When OIDC is enabled in a master-worker setup, only the internal administrator user can execute the archive policy. This is by design. If an external OIDC user runs the policy, it fails with the error java.lang.UnsupportedOperationException: Authentication method not supported. To purge tasks in this setup, run the policy as the internal administrator user, or rely on the scheduled automatic execution.