When we develop new features, we try to keep things simple, yet with no compromise to flexibility. A couple weeks ago we delivered parameterized builds. Although it was met with very positive feedback from the community, some users missed the option to parameterize executions via the API as well.

This option has just been delivered: from now on, you can run a pipeline via the API and pass the parameters that will be available in all actions.

Executions can be parameterized in 2 ways:

API Parameterization: Method #1

This way involves the run execution method. In the execution object you need to pass a list of variables in the following way:

"variables": [
      {
         "key": "version",
         "value": "1.0"
      },
      {
         "key": "pass",
         "value": "qwerty",
 	   "encrypted": true
      }
   ]

If you want to hide a value in the logs, add the field "encrypted": true to the variable object.

Running the execution via curl looks like this:

$ curl --header "Content-Type: application/json" \
--header "Authorization: Bearer $token" \
-X POST \
--data '{ "to_revision": { "revision": "HEAD" }, "comment": "hotfix", "variables": [{ "key": "notify_team", "value": "false" }]}' \
https://api.buddy.works/workspaces/buddy/projects/buddy-works/pipelines/1/executions

To the $token variable you need to assign your Personal account token which you can get here

API Parameterization: Method #2

This way involves the Pass parameters action. First, add this action as described here. Once the execution is waiting for arguments, you can resume it using the apply method:

$ curl --header "Content-Type: application/json" \
--header "Authorization: Bearer $token" \
-X PATCH \
--data '{ "operation": "APPLY_VARIABLES", "variables": [{ "key": "notify_team", "value": "false" }]}' \
https://api.buddy.works/workspaces/buddy/projects/buddy-works/pipelines/1/executions/4

Using parameters

All parameters sent to the execution are available as environment variables in our actions and can be used for various tasks. For example, to determine whether an action should be run or not. In such case, you can use a trigger condition that depends on variable value.