Environment variables & files

Provide additional build configuration for your project

Nevercode extends build configuration options by using a variety of variables and uploading relevant environment files and/or custom build scripts. Nevercode exports several read-only environment variables (which you can reference below) but also enables you to define your own custom variables.

This guide covers:

Overview of environment variables and files

Environment variables enable you to configure relevant variables for your builds. In Nevercode, these variables are categorized as follows:

  • Environment variables: exported as read-only by Nevercode and cannot be changed by the user. See the list here.
  • Custom environment variables: defined by you; custom variables will always override Nevercode defaults.
  • Magic variables: defined by you to fine-tune various aspects of your project(s). Read more about magic variables here.

Environment files are relevant files and scripts you can upload that should be used or be accessible in your project during the build.

  • Environment files: upload files that are not in your repository but should be available to your build scripts.
  • Custom build scripts: upload custom build scripts for specific build steps that you want to be run during the build process.

Read more about custom build scripts and steps here.

Defining custom environment variables

To define your own environment variables:

  1. Navigate to the Environment page in your project settings.
  2. Type the custom variable name and the corresponding value to the fields.
Adding a custom variable

Adding a custom variable

  1. Select Hidden if you wish to hide the value of the variable in Nevercode UI.
  2. Click Add variable to save your custom environment variable.

Alternatively, you can add several custom environment variables at once by uploading a text file. For that, click upload variables from the text file. Each variable must begin on a new row and have a name and a value, delimited by an equals sign. For example:

MY_VARIABLE_1=VARIABLE1
MY_VARIABLE_2=VARIABLE2
`

To edit the variable name or value:

  1. Click the field of the value and enter a new one.
  2. Press Enter to save or click the Save icon on the right.

To delete a variable, click the Delete icon on the right.

Adding custom environment files

Custom environment files are files that are not present in your source repository for your projects but that should be accessible from your build script.

To upload an environment file:

  1. Navigate to the Environment page in your project settings.
  2. In the Environment Files section, drag and drop your file to the upload area or click on it to browse and select from your file directory.
  3. Type the name of your file. Note that the entered name will be treated as environment variable and its value is the path to the uploaded file during the build.
  4. Click Save.
Adding a custom environment file

Adding a custom environment file

Example use case for custom environment files

For example, your build relies on a configuration file configs/config.json, but you'd like to have a different configuration for CI builds. Let's assume you've uploaded the desired configuration file ci_config.json as environment file and named it CI_CONFIG_JSON. Now, you could swap the original file for Nevercode builds in your repository with a simple post-clone script (read more about custom build steps here) as follows:

#!/bin/sh

mv $CI_CONFIG_JSON $NEVERCODE_BUILD_DIR/configs/config.json

where $NEVERCODE_BUILD_DIR points to the cloned repository path in Nevercode virtual machines.

Nevercode read-only environment variables

By default, Nevercode exports the following environment variables during all builds:

KEY
value

ANDROID_HOME

Path to Android SDK

ANDROID_NDK_HOME

Path to Android NDK

BUILD_NUMBER

Number of the build for this project in Nevercode

CI

true

CONTINUOUS_INTEGRATION

true

NEVERCODE

true

NEVERCODE_BRANCH

The current branch being built, for pull requests it is the destination branch

NEVERCODE_BUILD

true

NEVERCODE_BUILD_NUMBER

Number of the build for this project in Nevercode

NEVERCODE_BUILD_DIR

Absolute path to the cloned repository in Nevercode builders

NEVERCODE_BUILD_CONFIG

Config for Cordova (release or debug) and iOS (Release or Debug). Empty string for Android

NEVERCODE_BUILD_OUTPUT_DIR

Contains all of the artefact files that will be included in the final artefacts zip file

NEVERCODE_BUILD_PROJECT

Name of the project to be built. For iOS it is project.xcodeproj or project.xcworkspace, for Android it is the name of the Gradle subproject (like app) and empty string for Cordova/Ionic

NEVERCODE_BUILD_TARGET

Task for Android, Scheme or Target for iOS

NEVERCODE_BUILD_ID

UUID of the build

NEVERCODE_BUILD_STEP_STATUS

Build step status as success, failure or skipped.

NEVERCODE_BUILD_URL

Build's web URL

NEVERCODE_CLONE_UNSHALLOW

Performs a full clone of the repository instead of top 50 commits

NEVERCODE_COMMIT

Commit hash that is currently being built by Nevercode, for pull request builds it is hash of the source commit

NEVERCODE_EXPORT_DIR

All of the files included in this directory will be added to the artefacts zip file

NEVERCODE_FEATURE_BRANCH

true, if the current build is building a feature branch, false otherwise

NEVERCODE_GIT_PROVIDER_PULL_REQUEST

UUID of the pull request for the Git provider (Bitbucket, Github etc)

NEVERCODE_PLATFORM

Platform of the project that is being built, value is one of android, cordova, ionic, ios, react_native

NEVERCODE_PROJECT_ID

UUID of the project that is being built

NEVERCODE_ REPO_SLUG

The slug of the repository that is currently being built in the form owner_name/repository_name

NEVERCODE_TEST_STEP_STATUS

Get test step status success or failure

NEVERCODE_PULL_REQUEST

true, if the current build is building a pull request, false otherwise

NEVERCODE_PULL_REQUEST_DESTINATION

Name of the pull request's destination branch

NEVERCODE_PULL_REQUEST_SOURCE

Name of the pull request's source branch

NEVERCODE_PULL_REQUEST_REPO_SLUG

The slug of the PR source repository that is currently being built for PR builds, empty otherwise (owner_name/repository_name)

NEVERCODE_PULL_REQUEST_NUMBER

Integer ID of the pull request for the Git provider (Bitbucket, Github etc)

JAVA7_HOME

Path to Java 7

JAVA8_HOME

Path to Java 8

JAVA_HOME

Path to default Java, version 8 by default

NDK_HOME

Path to Android NDK

XUNIT_RESULTS_DIR

Directory for custom test results

Environment variables & files

Provide additional build configuration for your project