How to: Upload job artifacts without gitlab-runner
Problem to solve
I currently have a runner that runs SSH executor in order to build on a very specific tagret on which I can't install GitLab runner (basically because Go can't be fully functional on it).
I noticed that my jobs cannot upload artifacts because gitlab-runner is missing from the SSH target. (Which case is described in docs with "If you want to upload job artifacts, install gitlab-runner on the host you are connecting to through SSH.")
Further details
I tried a workaround pushing artifacts using API like this:
MySpecialJob:
extends: .commons
tags: ["my-special-target"]
stage: build
script:
- mkdir -p ./_output
- ./scripts/package.sh
- zip -r artifacts.zip ./_output/
- |
curl --request POST --header "JOB-TOKEN: $CI_JOB_TOKEN" --form "file=@artifacts.zip" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/${CI_JOB_ID}/artifacts?EXPIRE_IN=1hour"
- rm ./artifacts.zip
rules:
- !reference [.commons, rules]
But obviously, it doesn't work...
Proposal
API Documentation: Please provide official documentation on how to upload artifacts directly via the GitLab API. (Only working while a job is running of course...) There is no clear nor official guide for this use case.
Or
Minimal Standalone Uploader: Provide a lightweight, dependency-free (and Go-free) executable that can upload artifacts without requiring a full gitlab-runner installation. This would be especially useful for that kind of restricted environment.
Or
Handle artifacts upload with SSH executor without having to install gitlab-runner on the target.