Pass in pipeline variables in a commit/push

When you manually run a CI/CD Pipeline form the UI with “Run Pipeline” you can specify variables. I would like to know if this functionality exists from the CLI commit message/push. Essentially I would like my pipeline to run with user specific variables. For example the users IP address or the users credentials. So when a user pushes to the pipeline they need to input their own variables. Right now my plan is to parse the commit message for things like:

"trigger pipeline with IP:127.0.0.1"

for word in ${CI_COMMIT_MESSAGE}; do
    if [[ "${word}" == *":"* ]]; then
        variable=`echo $word | cut -d":" -f1`
        value=`echo $word | cut -d":" -f2`
        eval $variable="$value"
    fi
done

This isn’t pretty and may even be bad practice so I’m open to other suggestions but I think the best solution is to be able to set variables in the commit/push command.

I have just found that gitlab supports parsing the git push-options.

Eg.
git push -o ci.variable="MAX_RETRIES=10" -o ci.variable="MAX_TIME=600"

I haven’t tried it yet - but the documentation is here

1 Like

@geoff.lambourne did that work for you? I’ve just tried setting a variable (not a standard Gitlab one, but defined in my YAML) and the value gets ignored, it sticks to the default defined in the YAML.