webhook
webhook copied to clipboard
String formatting for command arguments
I'm using a CI tool called laminar, and to kick off a job, I need to be able to run a command like this:
laminarc queue job_name argname=argvalue
I admit that it's not a particularly ergonomic structure for the command, but it works very well for our needs. If there was some way to specify a format for an argument, this issue and other issues like it (such as #241 and #324) would be solved. I imagine something like this:
"pass-arguments-to-command": [
{
"source": "payload",
"name": "head_commit.id",
"format": "sha=%val"
}
]
In this way, you could provide arguments to pretty much any command with any kind of formatting that you could possibly want.
I know I can use a wrapper script to format the command if needed, but that's not a great solution if it can be avoided. It just seems messy.
Is this functionality something that you'd accept if a PR was opened?
Interesting request. My thoughts on how this could work:
The pass-arguments-to-command property shares the same type ([]Argument) as the pass-environment-to-command, pass-file-to-command, and parse-parameters-as-json options.
The simplest solution would be to add a format property similar to your example that is passed to fmt.Sprintf. So, your example would be:
{
"source": "payload",
"name": "head_commit.id",
"format": "sha=%s"
}
I can see how this feature could be used with pass-environment-to-command. It's less obvious to me why we would support its use with pass-file-to-command and parse-parameters-as-json.