Artifactory Artifact Cleanup Template (1.40 and higher)

JFrog Pipelines Documentation

Products
JFrog Pipelines
Content Type
User Guide
ft:sourceType
Paligo

The Artifactory Artifact Cleanup template is a Pipelines template that can be used to delete all Artifactory artifacts that have not been downloaded for the past n time units.

Prerequisites

  • Artifactory Artifact Cleanup template is available from Pipelines 1.31.2, but for following steps you need 1.40.

  • Artifactory version must be 7.49.0 or higher

Step 1: Create Integration

The Artifact Cleanup Template requires the following integration. For information about creating an integration, see Adding an Integration.

Integration Type

Integration Name

Comments

JFrog Platform Access Token Integration

  • jf_token

This integration is used to perform Artifactory operations and requires repository read/write permissions.

Step 2: Create Node Pools

For SaaS deployments, a node pool named default-dynamic-nodepool is available by default. For on-premise deployments, at least one node pool must be added and designated as the default node pool, and assigned at least one build node for pipelines to execute in the selected Project. For information about creating node pools, see Managing Pipelines Node Pools.

Step 3: Create Pipelines Source for Artifact Cleanup Template

  1. In your SCM repository, create a new directory named .jfrog-pipelines.

  2. In the directory, create two new files:

    • pipelines.yml

    • values.yml

  3. pipelines.yml: Add the following in the pipelines.yml file:

    valuesFilePath: ./values.yml
    include:
      template: jfrog/ArtifactCleanup/1.0.0

    Where:

    • valuesFilePath is the path where the values.yml file is stored.

  4. values.yml: Update the values.yml file to include the values required for the template. Here is a sample:

    shared:
      input:
        # [Required]
        jfrogTokenIntegration: jf_token
    
    artifactCleanup:
      metadata:
        # [Required]
        pipelineName: artifact_cleanup
    
        # [Optional] Default value: artifact_cleanup_property_bag
        propertyBagResourceName: artifact_cleanup_property_bag
    
        # [Optional] Default value: artifact_cleanup_cron_trigger
        cronTriggerResourceName: artifact_cleanup_cron_trigger
    
      controls:
        # [Optional] When defined with enabled: true then new Cron will be setup. Default expression: 0 0 5 ? * 1
        cron:
          enabled: false
          expression: "*/3 * * * *"
    
        # [Optional] List of comma separated Artifactory repo names for which jfrogTokenIntegration is provided.
        # Useful when using the pipeline with Cron.
        repos: "plugin-repo-1"
    
        # [Optional] Defaults to true, if not provided
        dryRun: "true"
    
        # [Optional] Defaults to 1000, if not provided
        paceTimeMS: 1000
    
        # [Optional] Defaults to 10, if not provided
        maxRepos: 10
    
        # [Optional] Defaults to 10, if not provided
        maxArtifacts: 100
    
    
    dockerCleanup:
      metadata:
        # [Required]
        pipelineName: docker_cleanup
    
        # [Optional] Default value: docker_cleanup_property_bag
        propertyBagResourceName: docker_cleanup_property_bag
    
        # [Optional] Default value: docker_cleanup_cron_trigger
        cronTriggerResourceName: docker_cleanup_cron_trigger
    
      controls:
        # [Optional] When defined with enabled: true then new Cron will be setup. Default expression: 0 0 5 ? * 1
        cron:
          enabled: false
          expression: "*/3 * * * *"
    
        # [Optional] List of comma separated Artifactory Docker repo names for which jfrogTokenIntegration is provided.
        # Useful when using the pipeline with Cron.
        repos: "km-docker-local"
    
        # [Optional] Defaults to true, if not provided
        dryRun: "false"
    
        # [Optional] Defaults to 1000, if not provided
        paceTimeMS: 1000
    
        # [Optional] Defaults to 10, if not provided
        maxRepos: 10
    
        # [Optional] Defaults to 10, if not provided
        maxArtifacts: 100

    The following parameters are mandatory:

    • jfrogTokenIntegration: Name of the JFrog Platform Access Token Integration that was created in Step 1.

    • artifactCleanup: Name of the artifactCleanup pipeline. This pipeline is used for cleaning up all artifacts except Docker.

    • pipelineName: Name of the DockerCleanup pipeline. This pipeline is used for cleaning up all Docker artifacts.

  5. In the JFrog Platform, go to Administration → Pipelines → Pipeline Sources and add the pipeline as a pipeline source.

    artifactCleanupSource.png

    After your Pipeline Source syncs successfully, you can view the newly added pipelines (artifact_cleanup and docker_artifact_cleanup) by navigating to My Pipelines on the left navbar and clicking PipelinesMy Pipelines.

    180146800.png
    180146801.png
  6. Go to Application → Pipelines → My Pipelines → All Pipelines, click either artifact_cleanup or docker_cleanup, click the custom trigger button and click the Environment Variables tab.

    180146807.png
  7. Click the Environment Variables tab and configure the available values as per your requirements. See the table below for information about each environment variable.