How do I keep job artifacts forever that are associated with a release, but expire all others?

Hi there,

I currently have a project that sets all job artifacts never to expire, and these artifacts are slowly filling my storage.

I’d love to be able to expire some of these artifacts, those that are not associated with a particular GL release (or were once, but the GL release has subsequently been deleted).

Here’s a little excerpt from my current pipeline

build_vm:
 stage: build_vm
  image: ubuntu:22.04
  rules:
    - if: $CI_COMMIT_TAG
 before_script:
    - echo The job ID is $CI_JOB_ID
      # Writing VM_JOB_ID variable to environment file, will need the value in the "Release" stage.
    - echo VM_JOB_ID=$CI_JOB_ID >> build.env
 script: 
   - ./build-vm.sh
 artifacts:
    reports:
      dotenv: build.env
    paths:
    - my_vm.qcow2
    expire_in: never 

release:
    name: 'My Project $CI_COMMIT_TAG'
    description: 'Created using the release-cli TAG=$CI_COMMIT_TAG'
    # tag_name is a mandatory field and can not be an empty string
    tag_name: '$CI_COMMIT_TAG'
    assets:
      links:
        - name: 'My Project VM QCOW2'
          url: 'https://my.gitlabserver.com/group/project/-/jobs/${VM_JOB_ID}/artifacts/download?file_type=archive'

Do you have any suggestions on how I can clean up job artifacts that aren’t associated with a Release? I’ve tried deleting orphaned job artifacts, but that doesn’t seem to help.

Many thanks for your time.
Nick