From 34a60daad1d241ffc6c05c8003468e7e2c57275b Mon Sep 17 00:00:00 2001 From: Ivan Nikiforov Date: Wed, 16 Oct 2024 16:09:51 +0200 Subject: [PATCH] Update documentation for scriptArguments param (#5128) * Update documentation for scriptArguments param * Update resources/metadata/shellExecute.yaml Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> * Update doc with new examples * Fix typo --------- Co-authored-by: Ivan Nikiforov Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> --- cmd/shellExecute_generated.go | 2 +- resources/metadata/shellExecute.yaml | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/shellExecute_generated.go b/cmd/shellExecute_generated.go index a69334c40f..3d0eeacb1a 100644 --- a/cmd/shellExecute_generated.go +++ b/cmd/shellExecute_generated.go @@ -142,7 +142,7 @@ func ShellExecuteCommand() *cobra.Command { func addShellExecuteFlags(cmd *cobra.Command, stepConfig *shellExecuteOptions) { cmd.Flags().StringSliceVar(&stepConfig.Sources, "sources", []string{}, "Scripts paths that must be present in the current workspace or https links to scripts. Only https urls from github are allowed and must be in the format :https://{githubBaseurl}/api/v3/repos/{owner}/{repository}/contents/{path to script} Authentication for the download is only supported via the 'githubToken' param. Make sure the script has the necessary execute permissions.") cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line") - cmd.Flags().StringSliceVar(&stepConfig.ScriptArguments, "scriptArguments", []string{}, "scriptArguments that are needed to be passed to scripts. the scriptArguments list is a flat list and has a positional relationship to the `sources` param. For e.g. The scriptArguments string at position 1 will be considered as the argument(s) for script at position 1 in `sources` list. For multiple arguments for a script please add them as a comma seperated string.") + cmd.Flags().StringSliceVar(&stepConfig.ScriptArguments, "scriptArguments", []string{}, "scriptArguments that need to be passed to the scripts.") } diff --git a/resources/metadata/shellExecute.yaml b/resources/metadata/shellExecute.yaml index c5a2a24605..32dafb73b3 100644 --- a/resources/metadata/shellExecute.yaml +++ b/resources/metadata/shellExecute.yaml @@ -42,8 +42,18 @@ spec: - PARAMETERS - STAGES - STEPS - description: scriptArguments that are needed to be passed to scripts. the scriptArguments list is a flat list and has a positional relationship to the `sources` param. - For e.g. The scriptArguments string at position 1 will be considered as the argument(s) for script at position 1 in `sources` list. For multiple arguments for a script please add them as a comma seperated string. + description: "scriptArguments that need to be passed to the scripts." + longDescription: |- + The scriptArguments list is a flat list and has a positional relationship to the `sources` parameter. + + For example, the `scriptArguments` string at position 0 will be considered as the argument(s) for script at position 0 in `sources` list. + `--sources ".pipeline/firstScript.sh" --sources ".pipeline/secondScript.sh" --scriptArguments "$(first_script_arg)" --scriptArguments "$(second_script_arg)"` + + For multiple arguments for a particular script, please add them as a comma-separated string enclosed in additional quotes, e.g.: + `--sources ".pipeline/yourScript.sh" --scriptArguments "\"$(first_arg),$(second_arg)\""` + + For multiple scripts with multiple arguments per each script your command would look like: + `--sources ".pipeline/firstScript.sh" --sources ".pipeline/secondScript.sh" --scriptArguments "\"$(first_script_arg1),$(first_script_arg2)\"" --scriptArguments "\"$(second_script_arg1),$(second_script_arg2)\""` mandatory: false containers: - name: shell