Conditional jobs lose artifacts and do not respect "keep artifacts from most recent successful jobs"
Summary
On a project with "Keep artifacts from most recent successful jobs", a job marked as conditional with rules:changes
will be reaped when the next pipeline runs regardless of whether or not the conditional job was included.
Steps to reproduce
#!/bin/sh
mkdir foo;
cd foo;
git init;
glab repo create;
GLCI=.gitlab-ci.yml
cat > "$GLCI" <<'EOF'
image: alpine:latest
stages:
- build
success:
stage: build
script:
- echo Success && exit 0;
build:
stage: build
script:
- mkdir dist
- echo "0" > dist/bar.txt
rules:
- changes:
- trigger.txt
artifacts:
expire_in: 5 seconds
paths:
- dist/*
EOF
#commit ci
git add "$GLCI";
git commit -m 'Add gitlab ci';
git branch --set-upstream-to=main
git push --set-upstream -o ci.skip origin main;
echo bump > trigger.txt
git add trigger.txt
git commit -a -m'trigger';
git push;
echo Check artifacts
Now observe the artifact above... kill it with this,
echo bump > notrigger.txt
git add notrigger.txt
git commit -a -m'no trigger';
git push;
Example Project
What is the current bug behavior?
Artifact is reaped.
What is the expected correct behavior?
Artifacts created by conditional jobs should be preserved until at least the next run of the conditional job which has created a newer artifact.
Also all of the documentation on rules:changes
should be updated with a mention of this. And like the documentation on "keep artifacts from most recent successful jobs".
Relevant logs and/or screenshots
Full write up can be found here, https://devops.stackexchange.com/questions/19237/how-do-you-preserve-conditionally-created-artifacts-artifacts-created-with-chan