KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Leveraging the --user-param Option in Tool4D for CI/CD Pipelines
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: August 26, 2025

In CI/CD pipelines, it is often necessary to automate database setup and configuration for different environments such as development, staging, or production. Running the database with specific parameters at launch allows the same structure file to behave differently based on the context, reducing manual intervention and improving consistency across builds.

Tool4D allows databases to be launched with command-line options that can customize behavior. Two key options in this case are:

- `--user-param` : Passes a custom user-defined string to the database at launch. This string can represent environment, build type, or any context-specific instruction.

- `--startup-method` : Specifies a method in the database to run immediately instead of 4D startup method, allowing automated actions based on the user parameter or other conditions.

To retrieve the value passed via --user-param inside the specified startup method, use the 4D command Get database parameter.


var $env : Text
var $result : Integer
$result:= Get database parameter(User param value; $env)

This allows conditional logic to be executed depending on the parameter value.


Example: Environment-Specific Setup


  • Command line launch:

  • Windows:

    .\tool4d\tool4d.exe .\myApp.4DProject --user-param "staging" --startup-method "setupEnvironment"


    macOS:

    ./tool4d/tool4d ./myApp.4DProject --user-param "staging" --startup-method "setupEnvironment"


  • Startup method (`setupEnvironment`):


  • // Retrieve the user parameter
    var $env : Text
    var $result : Integer
    $result := Get database parameter(User param value; $env)

    // Conditional logic based on the parameter
    Case of
      : ($env = "staging")
       // Configure database for staging environment
      : ($env = "production")
       // Configure database for production environment
    End case