assume the following:
- I have a build process that produces a binary and a log file
- both files are created even if the build command fails
- the build command takes a long time
I want to automate the build in this setup with GitLab CI/CD.
As a result I wish for:
- a link to the latest successfully build binary
- a link to the latest log file (especially if the build command fails)
One CI/CD configuration I can think about that realizes this is:
build: script: - build_command artifacts: paths: - binary create_log: script: - build_command artifacts: when: always paths: - log_file
However the costly
build_command is run here twice!
I can also not put the binary as an artifact in the second job (deleting the
first one since it would upload a broken artifact on failure).
An example for this type of build commands is given by LaTeX compilers.
Am I missing a possible solution?
Preferably I would be allowed to specify the when clause for every artifact
separately. This would allow the more efficient CI/CD configuration
build: script: - build_command artifacts: paths: on_success: - binary always: - log_file
It is probably not the most elegant way to introduce three new keywords
(always, on_success, on_failure) but it is better than having no way of
specifying the behaviour at all.
Thanks for any help.
PS: A similar question was asked here on StackOverflow.