Set Up Environment Variables
The BuildNinja Server and Agent rely on environment variables to define their configuration and communication parameters. These variables determine how the server manages builds, connects to the database, and handles authentication, as well as how the agent registers itself, communicates with the server, and stores local data.
If you install the server and agent using the installers, the essential environment variables are automatically configured. You only need to set additional variables if you wish to customize or extend the server and agent behavior according to your deployment requirements.
The following is a list of required and optional environment variables.
| Variable | Description | Windows Example | Linux Example | Category | Applies To | Configured by Installer |
|---|---|---|---|---|---|---|
| BN_SERVER_PUBLIC_URL | Base URL used in communication between the server and agents. | http://localhost:8800 | http://localhost:8800 | Required | Server | ❌ |
| BN_SERVER_MONGOURI | MongoDB connection URI used by the BuildNinja server to connect to a MongoDB instance. | mongodb://user:pass@localhost:27017/xxcicd_db?authSource=admin | mongodb://user:pass@localhost:27017/xxcicd_db?authSource=admin | Required | Server | ✅ |
| BN_SERVER_MONGODB | Name of the MongoDB database that BuildNinja connects to. | bn_server_stage | bn_server_stage | Required | Server | ✅ |
| BN_SERVER_JWT_SIGN_KEY | Secret key used by BuildNinja to sign JWT tokens, ensuring they are trusted and verifiable. | s3cure$ecretKey_123!xyz | s3cure$ecretKey_123!xyz | Required | Server | ✅ |
| BN_SERVER_PORT | Port number the BuildNinja server binds to (default: 8800). | 8800 | 8800 | Optional | Server | ✅ |
| BN_SERVER_DATA_DIR | Directory where BuildNinja stores internal data (temp files, assets, etc.). Default: {user_home}/bnserver/data | C:\BuildNinja\data | /var/lib/buildninja/data | Optional | Server | ✅ |
| BN_SERVER_SSL_CERT | File path to the server’s SSL/TLS certificate for HTTPS connections. | C:\certs\buildninja.crt | /etc/ssl/certs/buildninja.crt | Optional | Server | ❌ |
| BN_SERVER_SSL_KEY | File path to the server’s SSL/TLS private key for HTTPS connections. | C:\certs\buildninja.key | /etc/ssl/private/buildninja.key | Optional | Server | ❌ |
| BN_AGENT_NAME | Unique identifier for the BuildNinja agent. The server uses this name to register, manage, and distinguish agents. | agent-windows-01 | agent-linux-01 | Required | Agent | ✅ |
| BN_AGENT_PORT | Port on which the BuildNinja agent listens for internal communication and reporting (default: 9500). | 9500 | 9500 | Required | Agent | ✅ |
| BN_AGENT_SERVER_URL | URL of the BuildNinja server the agent connects to for registration, job assignments, and reporting. | http://192.168.1.100:8800 | http://192.168.1.100:8800 | Required | Agent | ✅ |
| BN_AGENT_SELFURL | Publicly accessible URL of the BuildNinja agent. Must be reachable by the server for job scheduling and communication. | http://192.168.1.51:9500 | http://192.168.1.52:9500 | Required | Agent | ✅ |
| BN_AGENT_DATA_DIR | Local path where the agent stores runtime data (e.g., temp files, artifacts, logs, cached dependencies). Default: {user_home}/bnagent/data | C:\BuildNinja\agent\data | /var/lib/buildninja/agent/data | Optional | Agent | ✅ |
When using the installers, all variables marked with ✅ are automatically configured during setup. You can modify or extend these variables later to customize your environment.
Next Steps
📄️ Set Up on Windows
Follow these steps to configure your environment variables on a Windows system.
📄️ Set Up on Linux
Follow these steps to configure your environment variables on a Linux system.
📄️ Troubleshooting
The following table lists common issues encountered during BuildNinja setup and operation, along with their respective solutions.