feat(ci): add support for job variables in CI trigger command
Description
This merge request adds support for job variables when triggering CI jobs via the glab ci trigger command.
Changes include:
- Added
--variablesflag: Pass environment variables to job in format<key>:<value> - Added
--variables-envflag: Pass environment variables to job in format<key>:<value> - Added
--variables-fileflag: Pass file contents as a file variable to job in format<key>:<filename> - Added
-f, --variables-fromflag: Load variables from a JSON file with array of hashes containing 'key' and 'value' fields
Implementation details:
- Added helper functions:
parseVarArg(),extractEnvVar(),extractFileVar(), andresolveJobVars()to parse and handle variable arguments - Updated
NewCmdTrigger()to accept the new flags and constructJobVariablesAttributesoptions - Updated documentation with usage examples showing how to pass variables
- All flags support multiple values (can be used multiple times)
Related Issues
Resolves #8005
How has this been tested?
This has been tested locally. Comprehensive unit tests have been added including:
- Test for triggering with a single variable
- Test for triggering with multiple variables
- Test for triggering with
--variables-envflag - Test for invalid variable format error handling
Edited by Swapnaneel Patra