Question
Conditionally display the drop-down list of values of a variable based the branch name GitLab pipeline
The globalvariables:
section of my .gitlab-ci.yml
file has been constructed like below:
variables:
HOST_NAME:
description: Select a host name to deploy
value: web-server-dev-01
options:
- web-server-dev-01
- web-server-dev-02
- web-server-dev-03
- web-server-prod-01
- web-server-prod-02
- web-server-prod-03
Now, when I run the pipeline, the HOST_NAME
variable shows the default value web-server-dev-01
and other 6 server names become available in the drop-down list of this variable, whichever branch I run from.
I'd like to make the values available like below:
- When running from
dev
branch, the default value of theHOST_NAME
should showweb-server-dev-01
and drop-down should show the first 3 server names (ending withdev-xx
). - When running from
master
branch, the default value of theHOST_NAME
should showweb-server-prod-01
and drop-down should show the last server names (ending withprod-xx
).
Is it possible? If so, would you please show how?
4 82
4