Skip to content

Allow env variable substitution in CLI client properties - #242

Merged
tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
VillePekka:issue-205
Feb 11, 2026
Merged

Allow env variable substitution in CLI client properties#242
tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
VillePekka:issue-205

Conversation

@VillePekka

@VillePekkaVillePekka commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Testing the functionality on Linux:

  1. In mirth-cli-config.properties file, define for example password as password=${env:OIE_PASSWORD}
  2. Define the environment variable in commandline export OIE_PASSWORD=<password>
  3. Run cli client ~/engine/server/setup$ java -jar mirth-cli-launcher.jar -c ../../command/conf/mirth-cli-config.properties

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds environment variable substitution support to the CLI client properties file by replacing the standard Java Properties class with Apache Commons Configuration2's Configuration interface. This allows users to specify property values like password=${env:OIE_PASSWORD} in the configuration file, which will be resolved from environment variables at runtime.

Changes:

  • Replaced Properties with Apache Commons Configuration2's Configuration for loading CLI configuration
  • Added new imports for Configuration2 classes
  • Modified configuration loading logic to use FileBasedConfigurationBuilder instead of direct file reading

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
Comment threadcommand/src/com/mirth/connect/cli/CommandLineInterface.java Outdated
@VillePekka

Copy link
Copy Markdown
ContributorAuthor

Plan is to next test different scenarios with both correct and incorrect credentials:
*** Login with user and password given on the command line
*** Login with config file
**** with credentials directly in the file
**** with credentials as environment variables
**** with mistyped environment variable

@tonygermano
tonygermanoforce-pushed the issue-205 branch 5 times, most recently from 2dc36ff to 4b8c71dCompareFebruary 10, 2026 11:20
…variables in config file.
Signed-off-by: Ville Ranta-aho <ville@ville-pekka.com>
Signed-off-by: Tony Germano <tony@germano.name>
@tonygermano
tonygermano marked this pull request as ready for review February 10, 2026 11:54

@tonygermanotonygermano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the following:

  • squashed all commits
  • fixed whitespace issues
  • rebased onto main
  • removed some unnecessary imports
  • reverted copilot suggestion and initialized config to empty BaseConfiguration

I tested all of your scenarios mentioned in #242 (comment)

I also tested with no config file

  • no command line arguments (shows help)
  • setting -a -u and -p on the command line (logs in if everything is valid)
  • setting -a and -u, but not -p (shows help)

@tonygermanotonygermano linked an issue Feb 10, 2026 that may be closed by this pull request
@tonygermano
tonygermano requested review from a team, NicoPiel, gibson9583, jonbartels, kayyagari, mgaffigan, pacmano1 and ssrowe and removed request for a teamFebruary 10, 2026 12:15

@mgaffiganmgaffigan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not test, but the changes look good.

@tonygermano
tonygermano merged commit da0757e into OpenIntegrationEngine:mainFeb 11, 2026
2 checks passed
@VillePekka

Copy link
Copy Markdown
ContributorAuthor

I did the following:

* squashed all commits
* fixed whitespace issues
* rebased onto main
* removed some unnecessary imports
* reverted copilot suggestion and initialized config to empty BaseConfiguration

I tested all of your scenarios mentioned in #242 (comment)

I also tested with no config file

* no command line arguments (shows help)
* setting -a -u and -p on the command line (logs in if everything is valid)
* setting -a and -u, but not -p (shows help)

Thank you @tonygermano !
Could you explain how you fixed whitespace issues, or give some pointer how to fix them in the future?
I tried with unix2dos command but that didn't seem to fix the issue.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[IDEA] Allow env variable substitution in CLI client properties

6 participants

@VillePekka@gibson9583@mgaffigan@tonygermano@pacmano1