Cannot create masked CI/CD project variable with API
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Hi there,
following the documentation on https://docs.gitlab.com/ee/api/project_level_variables.html#create-a-variable, I tried creating some project level CI/CD variables via curl. Unfortunately, the API does not accept the masked parameter as it should (or the documentation does not clearly state how it should be formatted)
I successfully created a plain variable with the following command curl -X POST -H "PRIVATE-TOKEN:MY_TOKEN" "https://www.gitlab.com/api/v4/projects/MY_PROJECT_ID/variables" -F "key=TESTING_KEY" -F "value=TESTING something"
However it throws an error when using the masked param.
curl -X POST \
-H "PRIVATE-TOKEN:MY_TOKEN" \
"https://www.gitlab.com/api/v4/projects/MY_PROJECT_ID/variables" \
-F "key=MASKED_TESTING_KEY" -F "value=TESTING masked as true" \
-F "masked=true"
returns {"message":{"value":["is invalid"]}}
Yet when you set masked=false, the variable is created as expected.
What exactly is the problem here? The documentation clearly states that the it's a boolean (I also tried TRUE, 1, but none worked)
Any help would be greatly appreciated!