[go: up one dir, main page]

Skip to content

Backend: "artifacts:expire_in" ignored when used in "default" section

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When specifying artifacts:expire_in in the default section, it is ignored and the project- or instance-level configuration is used. If specifying artifacts:expire_in in the individual job, this configuration is used.

The docs states that if artifacts:expire_in is not defined, the instance-level setting will be used: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html#with-an-expiry

If expire_in is not defined, the instance-wide setting is used.

And the docs also state that artifacts:expire_in can be used in the job and the default section: https://docs.gitlab.com/ee/ci/yaml/#artifactsexpire_in

Keyword type: Job keyword. You can use it only as part of a job or in the default section.

The expiration time period begins when the artifact is uploaded and stored on GitLab. If the expiry time is not defined, it defaults to the instance wide setting.

Steps to reproduce

This has been reproduced on GitLab self-managed and GitLab SaaS.

  1. Create a new project with the following .gitlab-ci.yml file:
default:
  artifacts:
    expire_in: 1 hour

stages:
  - build

build:
  stage: build
  script:
    - echo "Test" > echo.txt
  artifacts:
    paths:
      - echo.txt
  1. Modify the .gitlab-ci.yml file to have artifacts:expire_in: 1 hour in the build job definition

Example Project

https://gitlab.com/gitlab-gold/tmike/zd392663/zd392663/

What is the current bug behavior?

artifacts:expire_in is only used if defined in the job section.

What is the expected correct behavior?

artifacts:expire_in is used if defined in default or job section.

Relevant logs and/or screenshots

Output of checks

I checked the artifact expiry for each job in the Rails Console for self-managed test instance:

## When the `expire_in` is used in the default section:
  created_at: Tue, 04 Apr 2023 04:47:59.432044000 UTC +00:00,
  updated_at: Tue, 04 Apr 2023 04:47:59.432044000 UTC +00:00,
  expire_at: Thu, 04 May 2023 04:47:59.309787000 UTC +00:00,

## When the `expire_in` is used in the job section:
  created_at: Tue, 04 Apr 2023 04:55:21.144846000 UTC +00:00,
  updated_at: Tue, 04 Apr 2023 04:55:21.144846000 UTC +00:00,
  expire_at: Tue, 04 Apr 2023 05:55:21.137258000 UTC +00:00,

I checked the artifact expiry for each job via the Jobs API for the SaaS tests:

## Job 4055724025
"artifacts_expire_at":"2023-05-04T05:06:42.341Z"

## Job 4055735761
"artifacts_expire_at":"2023-04-04T06:10:53.238Z"

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by 🤖 GitLab Bot 🤖