Configuring your Build Pipeline for specific servers
DeployHQ offers a flexible build pipeline to prepare your code for deployment. By default, a single build configuration applies to all servers within your project. However, you can customize this to use specific settings for different environments, such as using a newer Node.js version for your Staging server while your production environment uses a more stable, older version.
This article explains how to configure server-specific build pipelines (BETA feature for the time being).
Understanding Default vs. Server-Specific Configurations
- Default Configuration: DeployHQ always starts with a default build pipeline configuration. As of today, this single configuration will be used for all deployments across all your servers unless an override is specified.
- Server-Specific Configurations: You have the ability to create distinct build configurations for individual servers or groups of servers. This allows for greater control over the build process for different environments (e.g., development, staging, production).
How to Configure Server-Specific Build Pipelines
1- Access Server Build Configurations: Navigate to your project in DeployHQ. Within your project settings or deployment configuration area, locate and click on "Server Build Configurations", as can be seen in the following screenshot:
2- Manage Configurations: Once in the "Server Build Configurations" area, you will see the existing default configuration. From here, you have two main options:
- Edit Default Settings: You can modify the default build pipeline settings that apply to all servers that do not have a specific override configuration.
- Create Server-Specific Configurations: This is where you can define unique build steps for particular servers or server groups.
- Click on an option like "New Build Configuration".
- You will typically be prompted to select the server or server group for which you want to create this specific configuration.
- You can then customize the build commands, environment variables, or specific software versions for this configuration. For example, to use Node.js version 22 for your "Staging" server while the default configuration uses Node.js 20, you would create a new configuration, assign it to the "Staging" server, and specify Node.js 22 within its settings.
- For example, you can use conditional logic in your build pipeline that evaluates the
%environment%
variable and runs appropriate commands. For example:
if [[ "%environment%" =~ ^(testing|staging)$ ]]; then
echo "Running commands for testing or staging environment..."
npm ci
npm run test
else
echo "Running default commands or commands for environment: %environment%"
npm ci
npm run build
fi
How Override Configurations are Applied
When you initiate a deployment to a server or a server group:
- DeployHQ will first check if a specific build configuration exists for that particular server or the group it belongs to.
- If a server-specific or group-specific configuration is found, that override configuration will be used for the build process, ignoring the default settings.
- If no specific configuration is found for the target server or its group, the default build pipeline configuration will be used.
Important Note on Server Group Configurations
- Please be aware that if DeployHQ finds more than one applicable custom configuration for a server group, it will not attempt to guess which one to use. In such scenarios, to ensure predictability and avoid conflicts, the default build pipeline configuration will be used instead. Therefore, it's crucial to ensure that your server group configurations are clearly defined and do not create ambiguity.
By leveraging server-specific build configurations, you can tailor your deployment pipeline to meet the unique requirements of each of your environments, leading to a more robust and reliable deployment process.
If you have any further questions or require assistance, please don't hesitate to contact our support team.