pages.expire_in does not accept variables
The pages.expire_in
setting behaves a little inconsistent. It seems to have this behavior:
if pages.expire_in == nil
# Default if parallel deployment
if pages.path_prefix
return '24 hours'
else
# Default if main deployment
return 'never'
end
else
return pages.expire_in
end
The problem which arises from this, is that increasing the expire_in
to e.g. one week
also sets one week
for the main
deployment. Unluckily one cannot use a variable to set expire_in
. And because one can just have one pages
job, either needs to rely on the default behavior, a high expire_in or never
. There is seems no way to have parallel deployments expire within time frame X while setting the main deployment to never
.
See also:
which was caused by: gitlab-org/gitlab-services/design.gitlab.com@99d85951
Workaround:
As Pages now supports User-defined job names, users can define multiple Pages jobs and set different expire_in
values for different rules.
Example:
main-pages:
stage: deploy
script:
- ...
pages: # specifies that this is a Pages job and publishes the default public directory
expire_in: never
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
mr-pages:
stage: deploy
script:
- ...
pages: # specifies that this is a Pages job and publishes the default public directory
expire_in: 1 week
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
Edited by Naman Jagdish Gala