Set job artifacts with tags to not expire

I am wondering is there any possibility to set job artifacts with tags to never expire while all other jobs should expire in the mentioned period.

I have had the same question in my head a few weeks ago and could not find anything about this in the docs.

I now have two build jobs configured, with the “tags” one having a long expiry time.

build_default:
    stage: build
    except: [ tags ]
    [...]
    artifacts:
        when: on_success
        expire_in: 42 weeks
        [...]

build_tags:
    stage: build
    only: [ tags ]
    [...]        
    artifacts:
        when: on_success
        expire_in: 42 years # why is there no "never" option?
        [...]

Hope it helps.

2 Likes

Yes, this is a solution. But it is not a nice solution if you have many stages in your yml. I think it is possible to avoid this using the GitLab API. Using the API you can check programmatically whether a commit is with a specific tag or not. And then based on that set the expiry for the job artifacts.