GitLab: URL shortcut to override pipeline variable values

GitLab pipelines are a convenient way to expose deployment/delivery tasks.  But with their rudimentary web UI for variable input, it can be challenging for users to populate the required list of variables.

One way of making it more convenient for end-users is to provide them a URL pre-populated with the specific branch and pipeline variable values.  The URL should have the following syntax:

https://gitlab/<project>/<repo>/-pipelines/new?ref=<branch>&var[varname]=thevalue

As an example, pressing “Run Pipeline” in my example GitLab project will render the pipeline variables with their default values from .gitlab-ci.yml

But, if you provided end-users a shortcut URL like below, you could change the branch and override any default pipeline variables using the syntax below.

https://gitlab.com/gitlab-pipeline7091038/gitlab-pipeline-variables/-/pipelines/new?ref=mybranch&var[PUBLISH_DIR]=/mydir&var[DEPLOY_ENV]=prod

 

 

REFERENCES

using to curl to start gitlab pipeline (needs token)

GitLab issue showing query params to pipeline

My example GitLab project for this article