Impossible to download job traces
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
This is a story of a lot of frustration. My goal was downloading job traces, so that I could send them in an email attachment... Coming from Jenkins background, this isn't exactly trivial, but is entirely doable, so, I was kind of hoping...
Problem 1
Existing options for mail sending are... ridiculously lacking. It is not possible to configure more than one recipient, mail is unconditionally sent to someone, usually unrelated to the job results. Well, basically, it doesn't work, and is beyond hope. So, I started by writing a little Python script that sends emails. Feels like 80s are back!
Problem 2
So, I found this documentation page, which boldly suggests that traces are job's artifacts: https://docs.gitlab.com/ee/administration/job_traces.html . Well, that turned out to be a lie. They aren't really job artifacts. They sit somewhere in the VM running gitlab-runner, completely inaccessible to the job that generated them.
Then I realized that I could simply scrape the page... you know when your job's log goes over some limit, there's a link that magically appears on the job's page directing you to the "raw" log. As a matter of fact, it's always there, not only when the job's log overflows. So, I said... why not curl ... Forget that it's idiotic to copy a file over HTTP, when it's already on the same system. Sometimes you just want things done, and the performance penalty of doing something idiotic doesn't scare you...
Well, that trick didn't work. curl got redirected to authentication page... FFS! I'm trying to download my own traces, how's that I need to authenticate for this? OK, I dug up the API reference: https://docs.gitlab.com/ee/api/jobs.html#get-a-trace-file supplied --header "PRIVATE-TOKEN: $CI_BUILD_TOKEN" -- you already see where this is going right? This token doesn't work. But... guys, I don't have any other token to authenticate with!