Skip to content

Commit 11e314d

Browse files
authored
Bulk uploading env vars to team settings (#3121)
* Bulk uploading env vars to team settings * Updating API for uploading environment variables in bulk * Update white-label-getting-started.md
1 parent 3549fdc commit 11e314d

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

content/yaml-quick-start/white-label-getting-started.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This group might contain the following environment variables:
5454
- **.env** file if your app uses some secrets at runtime. `DOTENV_FILE` (base64 encoded).
5555

5656

57-
To add these values you can either use the [Codemagic UI](https://docs.codemagic.io/yaml-basic-configuration/configuring-environment-variables/#configuring-environment-variables) or use the [Codemagic REST API](https://docs.codemagic.io/rest-api/codemagic-rest-api/) to add these groups and values programmatically, which could be advantageous if you have a large number of clients or wish to add these values from your own backend system or client dashboard.
57+
To add these values you can either use the [Codemagic UI](https://docs.codemagic.io/yaml-basic-configuration/configuring-environment-variables/#configuring-environment-variables) or use the [Codemagic REST API](https://codemagic.io/api/v3/schema#/) to add these groups and values programmatically, which could be advantageous if you have a large number of clients or wish to add these values from your own backend system or client dashboard.
5858

5959

6060
To add an environment variable using the Codemagic REST API, you need your API access token, the application id, the client group unique name, and the variable name and value.
@@ -66,22 +66,32 @@ To add an environment variable using the Codemagic REST API, you need your API a
6666
An example of adding a secret variable to an application group looks like this:
6767

6868
{{< highlight bash "style=paraiso-dark">}}
69-
curl -XPOST -H 'x-auth-token: <your-auth-token>' \
70-
-H 'Content-Type: application/json;charset=utf-8' \
71-
-d '{
72-
"key": "<variable-name>",
73-
"value": "<variable-value>"
74-
"group":"<client-unique-group-name>",
75-
"secure": true
76-
}' \
77-
'https://api.codemagic.io/apps/<app-id>/variables'
69+
curl --request POST \
70+
--url https://codemagic.io/api/v3/variable-groups/{variable_group_id}/variables \
71+
--header 'Accept: application/json' \
72+
--header 'Content-Type: application/json' \
73+
--header 'x-auth-token: $CODEMAGIC_AUTH_TOKEN' \
74+
--data '{
75+
"secure": true,
76+
"variables": [
77+
{
78+
"name": "string",
79+
"value": "string"
80+
}
81+
]
82+
}'
7883
{{< /highlight >}}
7984

85+
{{<notebox>}}
86+
💡 To find **{variable_group_id}**, a group needs to be created before uploading variables. More information can be found [here](https://codemagic.io/api/v3/schema#/) under the Secrets and Environment Vars dropdown.
87+
88+
{{</notebox>}}
89+
8090
{{<notebox>}}
8191
💡
8292
Files such as **Android keystores**, or **.env** files should be base64 encoded and can be passed like this:
8393

84-
`-d '{ "key": "<variable-name>", "value":`**`$(cat fileName | base64) ...`**
94+
`{ "name": "<variable-name>", "value":`**`$(cat fileName | base64) ...`**
8595

8696
And then decode it during the build like this:
8797

@@ -478,4 +488,4 @@ The **Codemagic REST API** can also be used for white label solutions where a da
478488

479489
You can find out more about the Codemagic REST API [here](../rest-api/codemagic-rest-api/)
480490

481-
Check out the white label sample project [here](https://github.com/codemagic-ci-cd/white-label-demo-project).
491+
Check out the white label sample project [here](https://github.com/codemagic-ci-cd/white-label-demo-project).

0 commit comments

Comments
 (0)