GItlab: has there any way we can select the variable values as drop down menu
Asked Answered
F

5

15

In Gitlab ci We have declared our variables like below

 USER_NAME:
    value: ""  
    description: "Enter Username"
  File_Name:
    description: "Enter the file name"

It only give a text box where We can enter the value.

Can I make a drop down select box is there any option available to make it a select box.Then we can select the value from drop down.

Faythe answered 29/10, 2021 at 5:20 Comment(0)
H
22

GitLab 15.7 (December 2022) has finally implemented this:

Select predefined CI/CD variables values from a dropdown list

Previously, you could pre-fill CI/CD variables in the “Run pipeline” page, with a specific value.

Unfortunately, if you had multiple options for the variable’s value, you still had to manually input the option you wanted. This was an error-prone process because you could easily input an invalid value, or just mistype it.

In this release, we’ve added the ability to set a list of values which are surfaced in a drop-down list in the “Run pipeline” page.

Now you can define the exact list of values that are valid for each CI/CD variable when running a pipeline manually, greatly simplifying your workflow when using manually-triggered pipelines.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfhWmf0cC2nZ7-sWV9QWRft/images/15_7/prefill.png -- Select predefined CI/CD variables values from a dropdown list

See Documentation and Issue.

Harbert answered 23/12, 2022 at 17:52 Comment(7)
Thanks to gitlab team...Thank you VonCFaythe
Could I do this in a dynamic way? For example, the values would be the name of the files in a given folder?Clang
@Clang Not sure, unless you can define a CI/CD variable dynamically in a file that you would then include in your main pipeline file.Harbert
how to select multiple values from the dropdown?Beggarweed
@Beggarweed To my knowledge, you would select only one value.Harbert
@Harbert is it possible to have a multi-value-select dropdown in gitlab ci/cd pipeline, with a comma separated values? something along the lines: multiselection: true, delimiter: ","Beggarweed
@Beggarweed Not that I know of. This was requested/noted in issue 29159. But not implemented yet.Harbert
O
4

From version 15.7 is available

variables:
  CONTENTFUL_ENV:
    value: "preview"
    options:
      - "preview"
      - "cdn"
    description: "The contentful env"
Outpatient answered 20/5, 2022 at 12:8 Comment(2)
I guess this is one of the most awaited features from Gitlab and also a reason for sticking to good old JenkinsTurquoise
@GovindKailas just in case you are still looking for this feature, please see my updated answerOutpatient
B
3

No it is not possible. What we ended up doing, if we want to have a better configurable way, was using the gitlab pages with a form, which will use the API or a POST to create a new pipeline. This way we are quiet flexible with the options to provide to the users.

Biamonte answered 29/10, 2021 at 5:31 Comment(1)
can you please provide the api that set the variable values and run itFaythe
V
2

I see an active proposal for it https://gitlab.com/gitlab-org/gitlab/-/issues/29159 (almost 2 years). But no activity for the moment.

Viewer answered 4/2, 2022 at 9:4 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Mroz
D
2

It's already implemented in GitLab v15.7 (https://docs.gitlab.com/ee/ci/pipelines/index.html#prefill-variables-in-manual-pipelines):

For example:

variables:
  DEPLOY_ENVIRONMENT:
    value: "staging"
    options:
      - "production"
      - "staging"
      - "canary"
    description: "The deployment target. Set to 'staging' by default."
Disquietude answered 2/2 at 13:16 Comment(2)
how to select multiple values from the dropdown?Beggarweed
@busuu, I don't see that this functionality is implemented in GitLab CI. So, you can't select multiply values from the dropdown. gitlab.com/gitlab-org/gitlab/-/issues/351067, gitlab.com/gitlab-org/gitlab/-/issues/417385.Disquietude

© 2022 - 2024 — McMap. All rights reserved.