Advanced project and environment management

Configuration files

Global Project Configuration

The 2 main things that define a project are its name and its home folder. Projects and environments as such are defined in the central Hop configuration file hop-config.json. By default this file lives in the config/ folder of your Hop client distribution. You can change that folder by setting the HOP_CONFIG_FOLDER environment variable on your system.

In hop-config.json, you’ll find a "projectsConfig" section. By default it contains the following:

  1. {
  2. "projectsConfig" : {
  3. "enabled" : true,
  4. "projectMandatory" : true,
  5. "environmentMandatory" : false,
  6. "defaultProject" : "default",
  7. "defaultEnvironment" : null,
  8. "standardParentProject" : "default",
  9. "standardProjectsFolder" : null,
  10. "projectConfigurations" : [ {
  11. "projectName" : "default",
  12. "projectHome" : "config/projects/default",
  13. "configFilename" : "project-config.json"
  14. }, {
  15. "projectName" : "samples",
  16. "projectHome" : "config/projects/samples",
  17. "configFilename" : "project-config.json"
  18. } ],
  19. "lifecycleEnvironments" : [ ],
  20. "projectLifecycles" : [ ]
  21. }
  22. }

As you can see the standard Hop client distribution defines 2 projects: default and samples.

Project Configuration

Every project has extra metadata and settings stored in a project configuration file called `project-config.json` . For the samples project this would be `config/projects/samples/project-config.json` . Let’s take a look at it:

  1. {
  2. "metadataBaseFolder" : "${PROJECT_HOME}/metadata",
  3. "unitTestsBasePath" : "${PROJECT_HOME}",
  4. "dataSetsCsvFolder" : "${PROJECT_HOME}/datasets",
  5. "enforcingExecutionInHome" : true,
  6. "parentProjectName" : "default",
  7. "config" : {
  8. "variables" : [ ]
  9. }
  10. }

Variables

You can define variables on a project level as well. This makes it handy to reference things like input and output folders which are not sensitive to being checked into version control.

Parent projects

As you can see from the project configuration file (parentProjectName), a project can have a parent from which it will inherit all the metadata objects as well as all the variables that are defined in it.

Environment configuration

Hop enviroments and their home folders are stored in the hop configuration file ‘hop-config.json’. That file lives by default in the config folder of the Hop installation. System property HOP_CONFIG_FOLDER can also be used to point to a different folder

  1. {
  2. "environmentConfig" : {
  3. "enabled" : true,
  4. "openingLastEnvironmentAtStartup" : true,
  5. "environmentConfigFilename" : "environment.json",
  6. "environmentFolders" : {
  7. "Project 1 - DEV" : "/projects/one/dev/",
  8. "Project 1 - UAT" : "/projects/one/uat/",
  9. "Project 1 - PRD" : "/projects/one/prd/",
  10. "Project 2 - DEV" : "/projects/two/dev/",
  11. "Project 2 - UAT" : "/projects/two/uat/",
  12. "Project 2 - PRD" : "/projects/two/prd/",
  13. }
  14. }

Command Line Project Configuration

In addition to the Hop Gui and configuration files, all aspects of and operations on projects and environments can be managed through the Hop Conf command line tool.

Configuration on the command line

The `hop-conf` script offers many options to edit environment definitions.

Creating an environment

  1. $ sh hop-conf.sh \
  2. --environment-create \
  3. --environment hop2 \
  4. --environment-project hop2 \
  5. --environment-purpose=Development \
  6. --environment-config-files=/home/user/projects/hop2-conf.json
  7. Creating environment 'hop2'
  8. Environment 'hop2' was created in Hop configuration file <path-to-hop>/config/hop-config.json
  9. 2021/02/01 16:37:02 - General - ERROR: Configuration file '/home/user/projects/hop2-conf.json' does not exist to read variables from.
  10. Created empty environment configuration file : /home/user/projects/hop2-conf.json
  11. hop2
  12. Purpose: Development
  13. Configuration files:
  14. Project name: hop2
  15. Config file: /home/user/projects/hop2-conf.json

As you can see from the log, an empty file was created to set variables in:

  1. { }

Setting variables in an environment

This command adds a variable to the environment configuration file:

  1. $ sh hop-conf.sh --config-file /home/user/projects/hop2-conf.json --config-file-set-variables DB_HOSTNAME=localhost,DB_PASSWORD=abcd
  2. Configuration file '/home/user/projects/hop2-conf.json' was modified.

If we look at the file `hop2-conf.json` we’ll see that the variables were added:

  1. {
  2. "variables" : [ {
  3. "name" : "DB_HOSTNAME",
  4. "value" : "localhost",
  5. "description" : ""
  6. }, {
  7. "name" : "DB_PASSWORD",
  8. "value" : "abcd",
  9. "description" : ""
  10. } ]
  11. }

Please note that you can add descriptions for the variables as well with the `--describe-variable` option. Please run hop-conf without options to see all the possibilities.

Deleting an environment

The following deletes an environment from the Hop configuration file:

  1. $ sh hop-conf.sh --environment-delete --environment hop2
  2. Lifecycle environment 'hop2' was deleted from Hop configuration file <path-to-hop>/config/hop-config.json

Projects Plugin configuration

There are various options to configure the behavior of the `Projects` plugin itself. In Hop configuration file `hop-config.json` we can find the following options:

  1. {
  2. "projectMandatory" : true,
  3. "environmentMandatory" : false,
  4. "defaultProject" : "default",
  5. "defaultEnvironment" : null,
  6. "standardParentProject" : "default",
  7. "standardProjectsFolder" : "/home/matt/test-stuff/"
  8. }
OptionDescriptionhop-conf option

projectMandatory

This will prevent anyone from using hop-run without specifying a project

—project-mandatory

environmentMandatory

This will prevent anyone from using hop-run without specifying an environment

—environment-mandatory

defaultProject

The default project to use when none is specified

—default-project

defaultEnvironment

The default environment to use when none is specified

—default-environment

standardParentProject

The standard parent project to propose when creating new project

—standard-parent-project

standardProjectsFolder

The folder to which you’ll browse by default in the GUI when creating new projects

—standard-projects-folder