{"_id":"590a04f6ed80861900cbc785","parentDoc":null,"user":"55b2d5626862a10d00887af9","__v":0,"version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"category":{"_id":"590a04f3ed80861900cbc73f","version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-02T17:55:17.903Z","from_sync":false,"order":7,"slug":"builds-and-tests","title":"Builds"},"project":"55b2d5baa74a380d00e290c4","updates":["57b8e74cc88a1e0e00f27992"],"next":{"pages":[],"description":""},"createdAt":"2016-07-12T18:36:32.431Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"You might have API keys and other secrets that your app needs to consume - either at runtime or during a build. However, you might not want to check these secrets into your source code to make them available to your app.\n\nIn order to securely propagate your credentials to your build and app, buddybuild provides three sets of variables that you can define:\n\n1. [Environment Variables](/docs/environment-variables) (made available to your build time scripts)\n2. [Device Variables](/docs/device-variables-1#section-step-1-create-device-variables-in-buddybuild) (available your App at runtime via the buddybuild SDK)\n3. [Secure Files](doc:secure-files) (files made available to your build time scripts)\n\nLet's get started with Secure Files!\n\n## Step 1: Upload a Secure File to buddybuild\n\nLaunch the buddybuild dashboard and select **App Settings**.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6fe1b91-Builds_-_Settings.png\",\n        \"Builds - Settings.png\",\n        1500,\n        483,\n        \"#ecf1f2\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nIn the left navigation, select **Build settings**, then **Secure files**.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3c75b6a-Settings_-_Secure_files_-_1.png\",\n        \"Settings - Secure files - 1.png\",\n        1500,\n        800,\n        \"#2a83d5\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nSelect the file you would like to upload and select **Upload file**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/784a735-Settings_-_Secure_files_-_2.png\",\n        \"Settings - Secure files - 2.png\",\n        1500,\n        729,\n        \"#e0e6eb\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nYour file is now ready to be consumed by your app.\n\n## Step 2: Consume the secure file in your build\n\nYour secure files will be automatically consumed by tools that are expecting them. \n\n## 2a. Consume in your custom build scripts.\nIf you would like to access them in your [custom build scripts](doc:custom-prebuild-and-postbuild-steps), use the bash variable expansion syntax.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"./Example.framework/run ${BUDDYBUILD_SECURE_FILES}/file.txt\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n## 2b. Consume in Android build.gradle file.\n\nIf you are building an **Android** app with **Gradle** (Android Studio), you can also access them 2 ways inside your **build.gradle** file\n\nYou can access them via **System.getenv()**, like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"signing.keyId=1234567\\nsigning.password=secret\\nsigning.secretKeyRingFile= new File(System.getenv(\\\"BUDDYBUILD_SECURE_FILES\\\") + \\\"/secring.gpg\\\")\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThat's it! For more details, refer to our [SDK API guide](http://docs.buddybuild.com/docs/sdk-api).","excerpt":"","slug":"secure-files","type":"basic","title":"Secure Files"}
You might have API keys and other secrets that your app needs to consume - either at runtime or during a build. However, you might not want to check these secrets into your source code to make them available to your app. In order to securely propagate your credentials to your build and app, buddybuild provides three sets of variables that you can define: 1. [Environment Variables](/docs/environment-variables) (made available to your build time scripts) 2. [Device Variables](/docs/device-variables-1#section-step-1-create-device-variables-in-buddybuild) (available your App at runtime via the buddybuild SDK) 3. [Secure Files](doc:secure-files) (files made available to your build time scripts) Let's get started with Secure Files! ## Step 1: Upload a Secure File to buddybuild Launch the buddybuild dashboard and select **App Settings**. [block:image] { "images": [ { "image": [ "https://files.readme.io/6fe1b91-Builds_-_Settings.png", "Builds - Settings.png", 1500, 483, "#ecf1f2" ], "sizing": "full" } ] } [/block] In the left navigation, select **Build settings**, then **Secure files**. [block:image] { "images": [ { "image": [ "https://files.readme.io/3c75b6a-Settings_-_Secure_files_-_1.png", "Settings - Secure files - 1.png", 1500, 800, "#2a83d5" ], "sizing": "full" } ] } [/block] Select the file you would like to upload and select **Upload file** [block:image] { "images": [ { "image": [ "https://files.readme.io/784a735-Settings_-_Secure_files_-_2.png", "Settings - Secure files - 2.png", 1500, 729, "#e0e6eb" ], "sizing": "full" } ] } [/block] Your file is now ready to be consumed by your app. ## Step 2: Consume the secure file in your build Your secure files will be automatically consumed by tools that are expecting them. ## 2a. Consume in your custom build scripts. If you would like to access them in your [custom build scripts](doc:custom-prebuild-and-postbuild-steps), use the bash variable expansion syntax. [block:code] { "codes": [ { "code": "./Example.framework/run ${BUDDYBUILD_SECURE_FILES}/file.txt", "language": "shell" } ] } [/block] ## 2b. Consume in Android build.gradle file. If you are building an **Android** app with **Gradle** (Android Studio), you can also access them 2 ways inside your **build.gradle** file You can access them via **System.getenv()**, like this: [block:code] { "codes": [ { "code": "signing.keyId=1234567\nsigning.password=secret\nsigning.secretKeyRingFile= new File(System.getenv(\"BUDDYBUILD_SECURE_FILES\") + \"/secring.gpg\")", "language": "json" } ] } [/block] That's it! For more details, refer to our [SDK API guide](http://docs.buddybuild.com/docs/sdk-api).