Passing the CI_JOB_TOKEN to a script

I’ve attempted this, but wanted to see if there was a solution I’ve missed. It appears that the job token is alive for the entirety of a CI job, however upon passing that to a bash script via command line args, it is unusable. I would like to download various job artifacts in a script that the CI job uses, however passing the job token to do this only downloads the redirected Sign In page. An example of what I’m doing is:

curl -L -o random.txt --header “JOB-TOKEN: $1” “gitlab.artifact.latest/download?job=rand”

download $1

In the CI configuration:


Any Ideas?