Environment variables & files

In this tutorial you'll get an overview of which environment variables are exported by Nevercode and how to define your own.

To be more precise, you'll see

Nevercode 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

Get build step status success or failure

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

Custom environment variables

To define your own environment variables navigate to project settings page by clicking on the spanner icon:

Open the Environment section. From there you can define your own environment variables which will be available during your builds.

Input your key=value pair to override the Nevercode defaults

Input your key=value pair to override the Nevercode defaults

Custom environment files

Custom environment files are those files not present in your source repository for your projects but can be accessible from your build script. To upload an environment file open your project setting page by clicking on the spanner icon (as can be seen above).

When your project settings screen is displayed, select the Environment section as shown above

Click on the add button (as can be seen on the picture) and this will open up a box for you to select/drop the file you wish to upload as indicated on this image below.

After selecting/dropping your preferred file you will be prompted to enter the name of your script as can be seen in the picture below. Simply enter your preferred name and click save. Entered name will be treated as environment variable and its value is the path to the uploaded file during the build.

Example

Say your build relies on a configuration file configs/config.json, but you'd like to have 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.

Environment variables & files