$CI_JOB_TOKEN starts with a - causes job to fail

Summary

Were getting sporadic failures in pipelines for the following command:

conan user ci_user -r <remote> -p $CI_JOB_TOKEN

Any time the CI_JOB_TOKEN variable started with a -, the command was trying to interpret the token as additional arguments. We were able to solve this by using the method recommended in the GitLab Conan documentation i.e. adding CONAN_LOGIN_USERNAME=ci_user CONAN_PASSWORD=${CI_JOB_TOKEN} before each of the Conan commands.

However this still seemed like something that may be worth addressing as this issue is not specific to Conan and could occur for any command which needs to pass in a password as a command line argument.

Example Project

This was done in a self-managed instance

What is the current bug behavior?

If the $CI_JOB_TOKEN starts with a - then the job would fail -- since the first character was intermittent, it was difficult to figure out the root cause

What is the expected correct behavior?

Do not allow for $CI_JOB_TOKEN to start with a -

Relevant logs and/or screenshots

n/a

Possible fixes

Edited by 🤖 GitLab Bot 🤖